code:     public static <T> Factory<T> prototypeFactory(final T prototype) {
          if (prototype == null) {
              return ConstantFactory.<T>constantFactory(null);
          }
          try {
              final Method method = prototype.getClass().getMethod("clone", (Class[]) null);
              return new PrototypeCloneFactory<T>(prototype, method);
  
          } catch (final NoSuchMethodException ex) {
              try {
                  prototype.getClass().getConstructor(new Class<?>[] { prototype.getClass() });
                  return new InstantiateFactory<T>(
                      (Class<T>) prototype.getClass(),
                      new Class<?>[] { prototype.getClass() },
                      new Object[] { prototype });
              } catch (final NoSuchMethodException ex2) {
                  if (prototype instanceof Serializable) {
                      return (Factory<T>) new PrototypeSerializationFactory<Serializable>((Serializable) prototype);
                  }
              }
          }
          throw new IllegalArgumentException("The prototype must be cloneable via a public clone method");
      }
  
      /**
       * Restricted constructor.
       */
  