net.sf.collections15.functors.transformer
Class FactoryTransformer<I,O>

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

public class FactoryTransformer<I,O>
extends java.lang.Object
implements Transformer<I,O>, java.io.Serializable

Transformer implementation whose transform(I) method uses a Factory to create the returned output object.

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

Constructor Summary
protected FactoryTransformer(Factory<O> factory)
          Creates a new instance that uses the specified Factory to create the transform output objects.
 
Method Summary
 Factory<O> getFactory()
          Returns the wrapped factory.
static
<I,O> Transformer<I,O>
getInstance(Factory<O> factory)
          Factory method that performs validation.
 O transform(I input)
          Transforms the input by ignoring the input and returning a new object created by the wrapped Factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FactoryTransformer

protected FactoryTransformer(Factory<O> factory)
Creates a new instance that uses the specified Factory to create the transform output objects.

Parameters:
factory - The Factory used to create the transform output objects.
Throws:
java.lang.IllegalArgumentException - Thrown if factory is null.
Method Detail

getInstance

public static <I,O> Transformer<I,O> getInstance(Factory<O> factory)
Factory method that performs validation.

Parameters:
factory - the factory to call, not null
Returns:
the factory transformer
Throws:
java.lang.IllegalArgumentException - if the factory is null

transform

public O transform(I input)
Transforms the input by ignoring the input and returning a new object created by the wrapped Factory.

Specified by:
transform in interface Transformer<I,O>
Parameters:
input - The input object, which is ignored.
Returns:
A new object created using the wrapped Factory.

getFactory

public Factory<O> getFactory()
Returns the wrapped factory.

Returns:
The wrapped factory.
Since:
Collections15 1.0


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