org.apache.commons.collections.functors
Class MapTransformer<I,O>

java.lang.Object
  extended by org.apache.commons.collections.functors.MapTransformer<I,O>
All Implemented Interfaces:
Serializable, Transformer<I,O>

public final class MapTransformer<I,O>
extends Object
implements Transformer<I,O>, Serializable

Transformer implementation that returns the value held in a specified map using the input parameter as a key.

Since:
Commons Collections 3.0
Version:
$Revision: 1.1.1.1 $ $Date: 2005/05/23 04:34:27 $
Author:
Matt Hall, John Watkinson, Stephen Colebourne
See Also:
Serialized Form

Method Summary
static
<I,O> Transformer<I,O>
getInstance(Map<I,O> map)
          Factory to create the transformer.
 Map<I,O> getMap()
          Gets the map to lookup in.
 O transform(I input)
          Transforms the input to result by looking it up in a Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static <I,O> Transformer<I,O> getInstance(Map<I,O> map)
Factory to create the transformer.

If the map is null, a transformer that always returns null is returned.

Parameters:
map - the map, not cloned
Returns:
the transformer

transform

public O transform(I input)
Transforms the input to result by looking it up in a Map.

Specified by:
transform in interface Transformer<I,O>
Parameters:
input - the input object to transform
Returns:
the transformed result

getMap

public Map<I,O> getMap()
Gets the map to lookup in.

Returns:
the map
Since:
Commons Collections 3.1


Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.