public class InstantiateFactory<T> extends java.lang.Object implements Factory<T>
WARNING: from v4.1 onwards this class will not be serializable anymore in order to prevent potential remote code execution exploits. Please refer to COLLECTIONS-580 for more details.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Object[] |
iArgs
The constructor arguments
|
private java.lang.Class<T> |
iClassToInstantiate
The class to create
|
private java.lang.reflect.Constructor<T> |
iConstructor
The constructor
|
private java.lang.Class<?>[] |
iParamTypes
The constructor parameter types
|
| Constructor and Description |
|---|
InstantiateFactory(java.lang.Class<T> classToInstantiate)
Constructor that performs no validation.
|
InstantiateFactory(java.lang.Class<T> classToInstantiate,
java.lang.Class<?>[] paramTypes,
java.lang.Object[] args)
Constructor that performs no validation.
|
| Modifier and Type | Method and Description |
|---|---|
T |
create()
Creates an object using the stored constructor.
|
private void |
findConstructor()
Find the Constructor for the class specified.
|
static <T> Factory<T> |
instantiateFactory(java.lang.Class<T> classToInstantiate,
java.lang.Class<?>[] paramTypes,
java.lang.Object[] args)
Factory method that performs validation.
|
private final java.lang.Class<T> iClassToInstantiate
private final java.lang.Class<?>[] iParamTypes
private final java.lang.Object[] iArgs
private transient java.lang.reflect.Constructor<T> iConstructor
public InstantiateFactory(java.lang.Class<T> classToInstantiate)
instantiateFactory if you want that.classToInstantiate - the class to instantiatepublic InstantiateFactory(java.lang.Class<T> classToInstantiate, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)
instantiateFactory if you want that.classToInstantiate - the class to instantiateparamTypes - the constructor parameter types, clonedargs - the constructor arguments, clonedpublic static <T> Factory<T> instantiateFactory(java.lang.Class<T> classToInstantiate, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)
T - the type the factory createsclassToInstantiate - the class to instantiate, not nullparamTypes - the constructor parameter types, clonedargs - the constructor arguments, clonedjava.lang.NullPointerException - if classToInstantiate is nulljava.lang.IllegalArgumentException - if paramTypes does not match argsprivate void findConstructor()