org.apache.commons.collections4.functors
Class InvokerTransformer<I,O>

java.lang.Object
  extended by org.apache.commons.collections4.functors.InvokerTransformer<I,O>
All Implemented Interfaces:
Serializable, Transformer<I,O>

public class InvokerTransformer<I,O>
extends Object
implements Transformer<I,O>, Serializable

Transformer implementation that creates a new object instance by reflection.

Since:
3.0
Version:
$Id: InvokerTransformer.java 1477839 2013-04-30 21:32:47Z tn $
See Also:
Serialized Form

Constructor Summary
InvokerTransformer(String methodName, Class<?>[] paramTypes, Object[] args)
          Constructor that performs no validation.
 
Method Summary
static
<I,O> Transformer<I,O>
invokerTransformer(String methodName)
          Gets an instance of this transformer calling a specific method with no arguments.
static
<I,O> Transformer<I,O>
invokerTransformer(String methodName, Class<?>[] paramTypes, Object[] args)
          Gets an instance of this transformer calling a specific method with specific values.
 O transform(Object input)
          Transforms the input to result by invoking a method on the input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InvokerTransformer

public InvokerTransformer(String methodName,
                          Class<?>[] paramTypes,
                          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 - the method to call
paramTypes - the constructor parameter types
args - the constructor arguments
Method Detail

invokerTransformer

public static <I,O> Transformer<I,O> invokerTransformer(String methodName)
Gets an instance of this transformer calling a specific method with no arguments.

Type Parameters:
I - the input type
O - the output type
Parameters:
methodName - the method name to call
Returns:
an invoker transformer
Since:
3.1

invokerTransformer

public static <I,O> Transformer<I,O> invokerTransformer(String methodName,
                                                        Class<?>[] paramTypes,
                                                        Object[] args)
Gets an instance of this transformer calling a specific method with specific values.

Type Parameters:
I - the input type
O - the output type
Parameters:
methodName - the method name to call
paramTypes - the parameter types of the method
args - the arguments to pass to the method
Returns:
an invoker transformer

transform

public O transform(Object input)
Transforms the input to result by invoking a method on the input.

Specified by:
transform in interface Transformer<I,O>
Parameters:
input - the input object to transform
Returns:
the transformed result, null if null input


Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.