org.apache.commons.collections.functors
Class ChainedClosure<T>

java.lang.Object
  extended by org.apache.commons.collections.functors.ChainedClosure<T>
All Implemented Interfaces:
Serializable, Closure<T>

public class ChainedClosure<T>
extends Object
implements Closure<T>, Serializable

Closure implementation that chains the specified closures together.

Since:
Commons Collections 3.0
Version:
$Revision: 1.1.1.1 $ $Date: 2005/05/23 04:34:14 $
Author:
Matt Hall, John Watkinson, Stephen Colebourne
See Also:
Serialized Form

Constructor Summary
ChainedClosure(Closure<? super T>[] closures)
          Constructor that performs no validation.
 
Method Summary
 void execute(T input)
          Execute a list of closures.
 Closure<? super T>[] getClosures()
          Gets the closures, do not modify the array.
static
<T> Closure<T>
getInstance(Closure<? super T>[] closures)
          Factory method that performs validation and copies the parameter array.
static
<T> Closure<T>
getInstance(Closure<? super T> closure1, Closure<? super T> closure2)
          Factory method that performs validation.
static
<T> Closure<T>
getInstance(Collection<? super T> closures)
          Create a new Closure that calls each closure in turn, passing the result into the next closure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChainedClosure

public ChainedClosure(Closure<? super T>[] closures)
Constructor that performs no validation. Use getInstance if you want that.

Parameters:
closures - the closures to chain, not copied, no nulls
Method Detail

getInstance

public static <T> Closure<T> getInstance(Closure<? super T>[] closures)
Factory method that performs validation and copies the parameter array.

Parameters:
closures - the closures to chain, copied, no nulls
Returns:
the chained closure
Throws:
IllegalArgumentException - if the closures array is null
IllegalArgumentException - if any closure in the array is null

getInstance

public static <T> Closure<T> getInstance(Collection<? super T> 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.

Parameters:
closures - a collection of closures to chain
Returns:
the chained closure
Throws:
IllegalArgumentException - if the closures collection is null
IllegalArgumentException - if any closure in the collection is null

getInstance

public static <T> Closure<T> getInstance(Closure<? super T> closure1,
                                         Closure<? super T> closure2)
Factory method that performs validation.

Parameters:
closure1 - the first closure, not null
closure2 - the second closure, not null
Returns:
the chained closure
Throws:
IllegalArgumentException - if either closure is null

execute

public void execute(T input)
Execute a list of closures.

Specified by:
execute in interface Closure<T>
Parameters:
input - the input object passed to each closure

getClosures

public Closure<? super T>[] getClosures()
Gets the closures, do not modify the array.

Returns:
the closures
Since:
Commons Collections 3.1


Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.