org.apache.commons.collections.functors

Class ChainedClosure

Implemented Interfaces:
Closure, Serializable

public class ChainedClosure
extends Object
implements Closure, Serializable

Closure implementation that chains the specified closures together.

Version:
$Revision: 1.5 $ $Date: 2004/03/13 17:17:03 $

Author:
Stephen Colebourne

Since:
Commons Collections 3.0

Constructor Summary

ChainedClosure(Closure[] closures)
Constructor that performs no validation.

Method Summary

void
execute(Object input)
Execute a list of closures.
Closure[]
getClosures()
Gets the closures, do not modify the array.
static Closure
getInstance(Collection closures)
Create a new Closure that calls each closure in turn, passing the result into the next closure.
static Closure
getInstance(Closure closure1, Closure closure2)
Factory method that performs validation.
static Closure
getInstance(Closure[] closures)
Factory method that performs validation and copies the parameter array.

Constructor Details

ChainedClosure

public ChainedClosure(Closure[] closures)
Constructor that performs no validation. Use getInstance if you want that.

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

Method Details

execute

public void execute(Object input)
Execute a list of closures.
Specified by:
execute in interface Closure

Parameters:
input - the input object passed to each closure


getClosures

public Closure[] getClosures()
Gets the closures, do not modify the array.

Returns:
the closures

Since:
Commons Collections 3.1


getInstance

public static Closure getInstance(Collection 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


getInstance

public static Closure getInstance(Closure closure1,
                                  Closure closure2)
Factory method that performs validation.

Parameters:
closure1 - the first closure, not null
closure2 - the second closure, not null

Returns:
the chained closure


getInstance

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

Parameters:
closures - the closures to chain, copied, no nulls

Returns:
the chained closure


Copyright © 2001-2005 Apache Software Foundation. All Rights Reserved.