Class InvokerTransformer<I,O>
- java.lang.Object
-
- org.apache.commons.collections4.functors.InvokerTransformer<I,O>
-
- All Implemented Interfaces:
Transformer<I,O>
public class InvokerTransformer<I,O> extends java.lang.Object implements Transformer<I,O>
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
-
-
Constructor Summary
Constructors Constructor Description InvokerTransformer(java.lang.String methodName, 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 static <I,O>
Transformer<I,O>invokerTransformer(java.lang.String methodName)Gets an instance of this transformer calling a specific method with no arguments.static <I,O>
Transformer<I,O>invokerTransformer(java.lang.String methodName, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)Gets an instance of this transformer calling a specific method with specific values.Otransform(java.lang.Object input)Transforms the input to result by invoking a method on the input.
-
-
-
Constructor Detail
-
InvokerTransformer
public InvokerTransformer(java.lang.String methodName, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)Constructor that performs no validation. UseinvokerTransformerif you want that.Note: from 4.0, the input parameters will be cloned
- Parameters:
methodName- the method to callparamTypes- the constructor parameter typesargs- the constructor arguments
-
-
Method Detail
-
invokerTransformer
public static <I,O> Transformer<I,O> invokerTransformer(java.lang.String methodName)
Gets an instance of this transformer calling a specific method with no arguments.- Type Parameters:
I- the input typeO- the output type- Parameters:
methodName- the method name to call- Returns:
- an invoker transformer
- Throws:
java.lang.NullPointerException- if methodName is null- Since:
- 3.1
-
invokerTransformer
public static <I,O> Transformer<I,O> invokerTransformer(java.lang.String methodName, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)
Gets an instance of this transformer calling a specific method with specific values.- Type Parameters:
I- the input typeO- the output type- Parameters:
methodName- the method name to callparamTypes- the parameter types of the methodargs- the arguments to pass to the method- Returns:
- an invoker transformer
- Throws:
java.lang.NullPointerException- if methodName is nulljava.lang.IllegalArgumentException- if paramTypes does not match args
-
transform
public O transform(java.lang.Object input)
Transforms the input to result by invoking a method on the input.- Specified by:
transformin interfaceTransformer<I,O>- Parameters:
input- the input object to transform- Returns:
- the transformed result, null if null input
-
-