org.apache.commons.collections.functors

Class ClosureTransformer

Implemented Interfaces:
Serializable, Transformer

public class ClosureTransformer
extends java.lang.Object
implements Transformer, Serializable

Transformer implementation that calls a Closure using the input object and then returns the input.

Version:
$Revision: 1.5 $ $Date: 2004/05/16 11:36:31 $

Author:
Stephen Colebourne

Since:
Commons Collections 3.0

Constructor Summary

ClosureTransformer(Closure closure)
Constructor that performs no validation.

Method Summary

Closure
getClosure()
Gets the closure.
static Transformer
getInstance(Closure closure)
Factory method that performs validation.
Object
transform(Object input)
Transforms the input to result by executing a closure.

Constructor Details

ClosureTransformer

public ClosureTransformer(Closure closure)
Constructor that performs no validation. Use getInstance if you want that.

Parameters:
closure - the closure to call, not null

Method Details

getClosure

public Closure getClosure()
Gets the closure.

Returns:
the closure

Since:
Commons Collections 3.1


getInstance

public static Transformer getInstance(Closure closure)
Factory method that performs validation.

Parameters:
closure - the closure to call, not null

Returns:
the closure transformer


transform

public Object transform(Object input)
Transforms the input to result by executing a closure.
Specified by:
transform in interface Transformer

Parameters:
input - the input object to transform

Returns:
the transformed result


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