Top Description Fields Constructors Methods
org.apache.commons.collections4.functors

public Class InstantiateTransformer<T>

extends Object
implements Transformer<Class<? extends T>, T>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.Transformer
Imports
java.lang.reflect.Constructor, .InvocationTargetException, org.apache.commons.collections4.FunctorException, .Transformer

Transformer 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

Modifier and TypeField and Description
private final Object[]
iArgs

The constructor arguments

private final Class<?>[]
iParamTypes

The constructor parameter types

private static final Transformer<I, O>
NO_ARG_INSTANCE

Singleton instance that uses the no arg constructor

Constructor Summary

AccessConstructor and Description
private
InstantiateTransformer()

Constructor for no arg instance.

public
InstantiateTransformer(final Class<?>[]
the constructor parameter types
paramTypes
,
final Object[]
the constructor arguments
args
)

Constructor that performs no validation.

Method Summary

Modifier and TypeMethod and Description
public static <
the type of the objects to be created
T
>
Transformer<Class<? extends T>, T>

Returns:

Transformer<Class<? extends T>, T>
instantiateTransformer
()

Get a typed no-arg instance.

public static <
the type of the objects to be created
T
>
Transformer<Class<? extends T>, T>

Returns:

an instantiate transformer
instantiateTransformer
(final Class<?>[]
the constructor parameter types
paramTypes
,
final Object[]
the constructor arguments
args
)

Transformer method that performs validation.

public T

Returns:

the transformed result
transform
(final Class<? extends T>
the input object to transform
input
)

Implements org.apache.commons.collections4.Transformer.transform.

Transforms the input Class object to a result by instantiation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iArgsback to summary
private final Object[] iArgs

The constructor arguments

iParamTypesback to summary
private final Class<?>[] iParamTypes

The constructor parameter types

NO_ARG_INSTANCEback to summary
private static final Transformer<I, O> NO_ARG_INSTANCE

Singleton instance that uses the no arg constructor

Annotations
@SuppressWarnings:rawtypes

Constructor Detail

InstantiateTransformerback to summary
private InstantiateTransformer()

Constructor for no arg instance.

InstantiateTransformerback to summary
public InstantiateTransformer(final Class<?>[] paramTypes, final Object[] args)

Constructor that performs no validation. Use instantiateTransformer if you want that.

Note

from 4.0, the input parameters will be cloned

Parameters
paramTypes:Class<?>[]

the constructor parameter types

args:Object[]

the constructor arguments

Method Detail

instantiateTransformerback to summary
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer()

Get a typed no-arg instance.

Parameters
<T>
the type of the objects to be created
Returns:Transformer<Class<? extends T>, T>

Transformer<Class<? extends T>, T>

instantiateTransformerback to summary
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(final Class<?>[] paramTypes, final Object[] args)

Transformer method that performs validation.

Parameters
<T>
the type of the objects to be created
paramTypes:Class<?>[]

the constructor parameter types

args:Object[]

the constructor arguments

Returns:Transformer<Class<? extends T>, T>

an instantiate transformer

Exceptions
IllegalArgumentException:
if paramTypes does not match args
transformback to summary
public T transform(final Class<? extends T> input)

Implements org.apache.commons.collections4.Transformer.transform.

Transforms the input Class object to a result by instantiation.

Parameters
input:Class<? extends T>

the input object to transform

Returns:T

the transformed result

Annotations
@Override