public class PrototypeFactory
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
PrototypeFactory.PrototypeCloneFactory<T>
PrototypeCloneFactory creates objects by copying a prototype using the clone method.
|
(package private) static class |
PrototypeFactory.PrototypeSerializationFactory<T extends java.io.Serializable>
PrototypeSerializationFactory creates objects by cloning a prototype using serialization.
|
| Modifier | Constructor and Description |
|---|---|
private |
PrototypeFactory()
Restricted constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> Factory<T> |
prototypeFactory(T prototype)
Factory method that performs validation.
|
public static <T> Factory<T> prototypeFactory(T prototype)
Creates a Factory that will return a clone of the same prototype object each time the factory is used. The prototype will be cloned using one of these techniques (in order):
WARNING: This method will return a Factory
that will throw an UnsupportedOperationException when trying to serialize
or de-serialize it to prevent potential remote code execution exploits.
In order to re-enable serialization support the following system property can be used (via -Dproperty=true):
org.apache.commons.collections.enableUnsafeSerialization
T - the type the factory createsprototype - the object to clone each time in the factoryprototype factory, or a ConstantFactory.NULL_INSTANCE if
the prototype is nulljava.lang.IllegalArgumentException - if the prototype cannot be cloned