Class InstantiateFactory<T>
- java.lang.Object
-
- org.apache.commons.collections4.functors.InstantiateFactory<T>
-
- All Implemented Interfaces:
Factory<T>
public class InstantiateFactory<T> extends java.lang.Object implements 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
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
create()
Creates an object using the stored constructor.static <T> Factory<T>
instantiateFactory(java.lang.Class<T> classToInstantiate, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)
Factory method that performs validation.
-
-
-
Constructor Detail
-
InstantiateFactory
public InstantiateFactory(java.lang.Class<T> classToInstantiate)
Constructor that performs no validation. UseinstantiateFactory
if you want that.- Parameters:
classToInstantiate
- the class to instantiate
-
InstantiateFactory
public InstantiateFactory(java.lang.Class<T> classToInstantiate, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)
Constructor that performs no validation. UseinstantiateFactory
if you want that.- Parameters:
classToInstantiate
- the class to instantiateparamTypes
- the constructor parameter types, clonedargs
- the constructor arguments, cloned
-
-
Method Detail
-
instantiateFactory
public static <T> Factory<T> instantiateFactory(java.lang.Class<T> classToInstantiate, java.lang.Class<?>[] paramTypes, java.lang.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:
java.lang.NullPointerException
- if classToInstantiate is nulljava.lang.IllegalArgumentException
- if paramTypes does not match args
-
-