Class ChainedClosure<T>
- java.lang.Object
-
- org.apache.commons.collections4.functors.ChainedClosure<T>
-
- Type Parameters:
T- the type of the input to the operation.
- All Implemented Interfaces:
java.io.Serializable,java.util.function.Consumer<T>,Closure<T>
public class ChainedClosure<T> extends java.lang.Object implements Closure<T>, java.io.Serializable
Closure implementation that chains the specified closures together.- Since:
- 3.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ChainedClosure(Closure<? super T>... closures)Constructor that performs no validation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E> Closure<E>chainedClosure(java.util.Collection<? extends Closure<? super E>> closures)Create a new Closure that calls each closure in turn, passing the result into the next closure.static <E> Closure<E>chainedClosure(Closure<? super E>... closures)Factory method that performs validation and copies the parameter array.voidexecute(T input)Execute a list of closures.Closure<? super T>[]getClosures()Gets the closures.
-
-
-
Constructor Detail
-
ChainedClosure
public ChainedClosure(Closure<? super T>... closures)
Constructor that performs no validation. UsechainedClosureif you want that.- Parameters:
closures- the closures to chain, copied, no nulls
-
-
Method Detail
-
chainedClosure
public static <E> Closure<E> chainedClosure(Closure<? super E>... closures)
Factory method that performs validation and copies the parameter array.- Type Parameters:
E- the type that the closure acts on- Parameters:
closures- the closures to chain, copied, no nulls- Returns:
- the
chainedclosure - Throws:
java.lang.NullPointerException- if the closures array is nulljava.lang.NullPointerException- if any closure in the array is null
-
chainedClosure
public static <E> Closure<E> chainedClosure(java.util.Collection<? extends Closure<? super E>> closures)
Create a new Closure that calls each closure in turn, passing the result into the next closure. The ordering is that of the iterator() method on the collection.- Type Parameters:
E- the type that the closure acts on- Parameters:
closures- a collection of closures to chain- Returns:
- the
chainedclosure - Throws:
java.lang.NullPointerException- if the closures collection is nulljava.lang.NullPointerException- if any closure in the collection is null
-
getClosures
public Closure<? super T>[] getClosures()
Gets the closures.- Returns:
- a copy of the closures
- Since:
- 3.1
-
-