Class InstantiateFactory<T>
java.lang.Object
org.apache.commons.collections4.functors.InstantiateFactory<T>
- All Implemented Interfaces:
Factory<T>
Factory implementation that creates a new object instance by reflection.
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.
- Since:
- 3.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Object[]The constructor argumentsThe class to createprivate Constructor<T> The constructorprivate final Class<?>[]The constructor parameter types -
Constructor Summary
ConstructorsConstructorDescriptionInstantiateFactory(Class<T> classToInstantiate) Constructor that performs no validation.InstantiateFactory(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args) Constructor that performs no validation. -
Method Summary
Modifier and TypeMethodDescriptioncreate()Creates an object using the stored constructor.private voidFind the Constructor for the class specified.static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args) Factory method that performs validation.
-
Field Details
-
iClassToInstantiate
-
iParamTypes
The constructor parameter types -
iArgs
The constructor arguments -
iConstructor
The constructor
-
-
Constructor Details
-
InstantiateFactory
-
InstantiateFactory
Constructor that performs no validation. UseinstantiateFactoryif you want that.- Parameters:
classToInstantiate- the class to instantiateparamTypes- the constructor parameter types, clonedargs- the constructor arguments, cloned
-
-
Method Details
-
instantiateFactory
public static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args) Factory method that performs validation.- Type Parameters:
T- the type the factory creates- Parameters:
classToInstantiate- the class to instantiate, not nullparamTypes- the constructor parameter types, clonedargs- the constructor arguments, cloned- Returns:
- a new instantiate factory
- Throws:
NullPointerException- if classToInstantiate is nullIllegalArgumentException- if paramTypes does not match args
-
findConstructor
private void findConstructor()Find the Constructor for the class specified. -
create
-