Class ChainedTransformer<T>
java.lang.Object
org.apache.commons.collections4.functors.ChainedTransformer<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 chains the specified transformers together.
The input object is passed to the first transformer. The transformed result is passed to the second transformer and so on.
- Since:
- 3.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Transformer[]private final Transformer<? super T,? extends T>[] The transformers to call in turnprivate static final longSerial version UID -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateChainedTransformer(boolean clone, Transformer<? super T, ? extends T>[] transformers) Hidden constructor for the use by the static factory methods.ChainedTransformer(Transformer<? super T, ? extends T>... transformers) Constructor that performs no validation. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Transformer<T, T> chainedTransformer(Collection<? extends Transformer<? super T, ? extends T>> transformers) Create a new Transformer that calls each transformer in turn, passing the result into the next transformer.static <T> Transformer<T, T> chainedTransformer(Transformer<? super T, ? extends T>... transformers) Factory method that performs validation and copies the parameter array.Transformer<? super T,? extends T>[] Gets the transformers.Transforms the input to result via each decorated transformerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.collections4.Transformer
apply
-
Field Details
-
EMPTY_TRANSFORMER_ARRAY
-
serialVersionUID
private static final long serialVersionUIDSerial version UID- See Also:
-
iTransformers
The transformers to call in turn
-
-
Constructor Details
-
ChainedTransformer
Hidden constructor for the use by the static factory methods.- Parameters:
clone- iftruethe input argument will be clonedtransformers- the transformers to chain, no nulls
-
ChainedTransformer
Constructor that performs no validation. UsechainedTransformerif you want that.- Parameters:
transformers- the transformers to chain, copied, no nulls
-
-
Method Details
-
chainedTransformer
public static <T> Transformer<T,T> chainedTransformer(Collection<? extends Transformer<? super T, ? extends T>> transformers) Create a new Transformer that calls each transformer in turn, passing the result into the next transformer. The ordering is that of the iterator() method on the collection.- Type Parameters:
T- the object type- Parameters:
transformers- a collection of transformers to chain- Returns:
- the
chainedtransformer - Throws:
NullPointerException- if the transformers collection is nullNullPointerException- if any transformer in the collection is null
-
chainedTransformer
public static <T> Transformer<T,T> chainedTransformer(Transformer<? super T, ? extends T>... transformers) Factory method that performs validation and copies the parameter array.- Type Parameters:
T- the object type- Parameters:
transformers- the transformers to chain, copied, no nulls- Returns:
- the
chainedtransformer - Throws:
NullPointerException- if the transformers array is nullNullPointerException- if any transformer in the array is null
-
getTransformers
Gets the transformers.- Returns:
- a copy of the transformers
- Since:
- 3.1
-
transform
Transforms the input to result via each decorated transformer- Specified by:
transformin interfaceTransformer<T,T> - Parameters:
object- the input object passed to the first transformer- Returns:
- the transformed result
-