Class ClosureTransformer<T>
java.lang.Object
org.apache.commons.collections4.functors.ClosureTransformer<T>
- Type Parameters:
T
- the type of the input and result to the function.
- All Implemented Interfaces:
Serializable
,Function<T,
,T> Transformer<T,
T>
Transformer implementation that calls a Closure using the input object
and then returns the input.
- Since:
- 3.0
- See Also:
-
Constructor Summary
ConstructorDescriptionClosureTransformer
(Closure<? super T> closure) Constructor that performs no validation. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Transformer
<T, T> closureTransformer
(Closure<? super T> closure) Factory method that performs validation.Gets the closure.Transforms the input to result by executing a closure.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.commons.collections4.Transformer
apply
-
Constructor Details
-
ClosureTransformer
Constructor that performs no validation. UseclosureTransformer
if you want that.- Parameters:
closure
- the closure to call, not null
-
-
Method Details
-
closureTransformer
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:
NullPointerException
- if the closure is null
-
getClosure
Gets the closure.- Returns:
- the closure
- Since:
- 3.1
-
transform
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
-