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

public Class ClosureTransformer<T>

extends Object
implements Transformer<T, T>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.collections4.Transformer
Imports
java.io.Serializable, org.apache.commons.collections4.Closure, .Transformer

Transformer implementation that calls a Closure using the input object and then returns the input.
Since
3.0

Field Summary

Modifier and TypeField and Description
private final Closure<? super T>
iClosure

The closure to wrap

private static final long
serialVersionUID

Serial version UID

Constructor Summary

AccessConstructor and Description
public
ClosureTransformer(final Closure<? super T>
the closure to call, not null
closure
)

Constructor that performs no validation.

Method Summary

Modifier and TypeMethod and Description
public static <
the type of the object to transform
T
>
Transformer<T, T>

Returns:

the closure transformer
closureTransformer
(final Closure<? super T>
the closure to call, not null
closure
)

Factory method that performs validation.

public Closure<? super T>

Returns:

the closure
getClosure
()

Gets the closure.

public T

Returns:

the transformed result
transform
(final T
the input object to transform
input
)

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

Transforms the input to result by executing a closure.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iClosureback to summary
private final Closure<? super T> iClosure

The closure to wrap

serialVersionUIDback to summary
private static final long serialVersionUID

Serial version UID

Constructor Detail

ClosureTransformerback to summary
public ClosureTransformer(final Closure<? super T> closure)

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

Parameters
closure:Closure<? super T>

the closure to call, not null

Method Detail

closureTransformerback to summary
public static <T> Transformer<T, T> closureTransformer(final Closure<? super T> closure)

Factory method that performs validation.

Parameters
<T>
the type of the object to transform
closure:Closure<? super T>

the closure to call, not null

Returns:Transformer<T, T>

the closure transformer

Exceptions
NullPointerException:
if the closure is null
getClosureback to summary
public Closure<? super T> getClosure()

Gets the closure.

Returns:Closure<? super T>

the closure

Since
3.1
transformback to summary
public T transform(final T input)

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

Transforms the input to result by executing a closure.

Parameters
input:T

the input object to transform

Returns:T

the transformed result

Annotations
@Override