org.springframework.core.closure.support
Class ClosureChain

java.lang.Object
  extended by org.springframework.core.closure.support.ClosureChain
All Implemented Interfaces:
Closure

public class ClosureChain
extends Object
implements Closure

A chain of closures that evaluate their results in a ordered sequence.

For example, declaring new ClosureChain() { f1, f2, f3 }.call(fooArg) will trigger the evaluation of f1 first, it's result will be passed to f2 for evaluation, and f2's result will be passed to f3 for evaluation. The final f3 result will be returned to the caller.

Author:
Keith Donald

Constructor Summary
ClosureChain()
          Constructs a function chain with no initial members.
ClosureChain(Closure[] functions)
          Creates a chain composed of the ordered array of functions.
ClosureChain(Closure function1, Closure function2)
          Creates a chain composed of two functions.
 
Method Summary
 ClosureChain add(Closure function)
          Add the specified function to the set of functions aggregated by this function chain.
 Object call(Object argument)
          Evaluate the function with the provided argument, returning the result.
 Iterator iterator()
          Return an iterator over the aggregated predicates.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClosureChain

public ClosureChain()
Constructs a function chain with no initial members. It is expected the client will call "add" to add individual predicates.


ClosureChain

public ClosureChain(Closure function1,
                    Closure function2)
Creates a chain composed of two functions.

Parameters:
function1 - the first function
function2 - the second function

ClosureChain

public ClosureChain(Closure[] functions)
Creates a chain composed of the ordered array of functions.

Parameters:
functions - the aggregated functions
Method Detail

add

public ClosureChain add(Closure function)
Add the specified function to the set of functions aggregated by this function chain.

Parameters:
function - the function to add
Returns:
A reference to this, to support easy chaining.

iterator

public Iterator iterator()
Return an iterator over the aggregated predicates.

Returns:
An iterator

call

public Object call(Object argument)
Evaluate the function with the provided argument, returning the result.

Specified by:
call in interface Closure
Parameters:
argument - the argument
Returns:
the function return value

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.