net.sf.collections15.functors.transformer
Class ClosureTransformer<E>

java.lang.Object
  extended by net.sf.collections15.functors.transformer.ClosureTransformer<E>
All Implemented Interfaces:
java.io.Serializable, Transformer<E,E>

public class ClosureTransformer<E>
extends java.lang.Object
implements Transformer<E,E>, java.io.Serializable

Transformer implementation that invokes a Closure using the input object, before returning the input object.

Since:
Collections15 1.0
Author:
Stephen Colebourne, Chris Lambrou (port to Java 5.0)
See Also:
Serialized Form

Constructor Summary
protected ClosureTransformer(Closure<? super E> closure)
          Creates a new instance whose transform method executes the specified Closure on an input object, before returning the input object as output.
 
Method Summary
static
<T> ClosureTransformer<T>
getInstance(Closure<? super T> closure)
          Returns an instance whose transform method executes the specified Closure on an input object, before returning the input object as the output.
 E transform(E input)
          Transforms the input by executing the Closure on the input, and then returning is as output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClosureTransformer

protected ClosureTransformer(Closure<? super E> closure)
Creates a new instance whose transform method executes the specified Closure on an input object, before returning the input object as output.

Parameters:
closure - The Closure to execute on input objects.
Throws:
java.lang.IllegalArgumentException - Thrown if closure is null.
Method Detail

getInstance

public static <T> ClosureTransformer<T> getInstance(Closure<? super T> closure)
Returns an instance whose transform method executes the specified Closure on an input object, before returning the input object as the output.

Parameters:
closure - The Closure to execute on input objects.
Returns:
An instance whose transform method executes the specified Closure on an input object, before returning the input object as the output.
Throws:
java.lang.IllegalArgumentException - Thrown if closure is null.

transform

public E transform(E input)
Transforms the input by executing the Closure on the input, and then returning is as output.

Specified by:
transform in interface Transformer<E,E>
Parameters:
input - The input object to transform.
Returns:
The input object, after the Closure has been executed on it.


Copyright © 2001-2005 SourceForge.net. All Rights Reserved.