org.apache.commons.collections.functors

Class ClosureTransformer

public class ClosureTransformer extends Object implements Transformer, Serializable

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

Since: Commons Collections 3.0

Version: $Revision: 348444 $ $Date: 2005-11-23 14:06:56 +0000 (Wed, 23 Nov 2005) $

Author: Stephen Colebourne

Constructor Summary
ClosureTransformer(Closure closure)
Constructor that performs no validation.
Method Summary
ClosuregetClosure()
Gets the closure.
static TransformergetInstance(Closure closure)
Factory method that performs validation.
Objecttransform(Object input)
Transforms the input to result by executing a closure.

Constructor Detail

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 Detail

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

Throws: IllegalArgumentException if the closure is null

transform

public Object transform(Object input)
Transforms the input to result by executing a closure.

Parameters: input the input object to transform

Returns: the transformed result

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