Class ClosureTransformer<T>
- java.lang.Object
-
- org.apache.commons.collections4.functors.ClosureTransformer<T>
-
- All Implemented Interfaces:
java.io.Serializable
,Transformer<T,T>
public class ClosureTransformer<T> extends java.lang.Object implements Transformer<T,T>, java.io.Serializable
Transformer implementation that calls a Closure using the input object and then returns the input.- Since:
- 3.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ClosureTransformer(Closure<? super T> closure)
Constructor that performs no validation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Transformer<T,T>
closureTransformer(Closure<? super T> closure)
Factory method that performs validation.Closure<? super T>
getClosure()
Gets the closure.T
transform(T input)
Transforms the input to result by executing a closure.
-
-
-
Method Detail
-
closureTransformer
public static <T> Transformer<T,T> closureTransformer(Closure<? super T> closure)
Factory method that performs validation.- Type Parameters:
T
- the type of the object to transform- Parameters:
closure
- the closure to call, not null- Returns:
- the
closure
transformer - Throws:
java.lang.NullPointerException
- if the closure is null
-
transform
public T transform(T input)
Transforms the input to result by executing a closure.- Specified by:
transform
in interfaceTransformer<T,T>
- Parameters:
input
- the input object to transform- Returns:
- the transformed result
-
-