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

public Class InvokerTransformer<I, O>

extends Object
implements Transformer<I, O>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.Transformer
Imports
java.lang.reflect.InvocationTargetException, .Method, 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 array of reflection arguments

private final String
iMethodName

The method name to call

private final Class<?>[]
iParamTypes

The array of reflection parameter types

Constructor Summary

AccessConstructor and Description
private
InvokerTransformer(final String
the method to call
methodName
)

Constructor for no arg instance.

public
InvokerTransformer(final String
the method to call
methodName
,
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 input type
I
,
the output type
O
>
Transformer<I, O>

Returns:

an invoker transformer
invokerTransformer
(final String
the method name to call
methodName
)

Gets an instance of this transformer calling a specific method with no arguments.

public static <
the input type
I
,
the output type
O
>
Transformer<I, O>

Returns:

an invoker transformer
invokerTransformer
(final String
the method name to call
methodName
,
final Class<?>[]
the parameter types of the method
paramTypes
,
final Object[]
the arguments to pass to the method
args
)

Gets an instance of this transformer calling a specific method with specific values.

public O

Returns:

the transformed result, null if null input
transform
(final Object
the input object to transform
input
)

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

Transforms the input to result by invoking a method on the input.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iArgsback to summary
private final Object[] iArgs

The array of reflection arguments

iMethodNameback to summary
private final String iMethodName

The method name to call

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

The array of reflection parameter types

Constructor Detail

InvokerTransformerback to summary
private InvokerTransformer(final String methodName)

Constructor for no arg instance.

Parameters
methodName:String

the method to call

InvokerTransformerback to summary
public InvokerTransformer(final String methodName, final Class<?>[] paramTypes, final Object[] args)

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

Note

from 4.0, the input parameters will be cloned

Parameters
methodName:String

the method to call

paramTypes:Class<?>[]

the constructor parameter types

args:Object[]

the constructor arguments

Method Detail

invokerTransformerback to summary
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName)

Gets an instance of this transformer calling a specific method with no arguments.

Parameters
<I>
the input type
<O>
the output type
methodName:String

the method name to call

Returns:Transformer<I, O>

an invoker transformer

Exceptions
NullPointerException:
if methodName is null
Since
3.1
invokerTransformerback to summary
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName, final Class<?>[] paramTypes, final Object[] args)

Gets an instance of this transformer calling a specific method with specific values.

Parameters
<I>
the input type
<O>
the output type
methodName:String

the method name to call

paramTypes:Class<?>[]

the parameter types of the method

args:Object[]

the arguments to pass to the method

Returns:Transformer<I, O>

an invoker transformer

Exceptions
NullPointerException:
if methodName is null
IllegalArgumentException:
if paramTypes does not match args
transformback to summary
public O transform(final Object input)

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

Transforms the input to result by invoking a method on the input.

Parameters
input:Object

the input object to transform

Returns:O

the transformed result, null if null input

Annotations
@Override
@SuppressWarnings:unchecked