Class MapTransformer<I,O>
- java.lang.Object
-
- org.apache.commons.collections4.functors.MapTransformer<I,O>
-
- All Implemented Interfaces:
java.io.Serializable
,Transformer<I,O>
public final class MapTransformer<I,O> extends java.lang.Object implements Transformer<I,O>, java.io.Serializable
Transformer implementation that returns the value held in a specified map using the input parameter as a key.- Since:
- 3.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<? super I,? extends O>
getMap()
Gets the map to lookup in.static <I,O>
Transformer<I,O>mapTransformer(java.util.Map<? super I,? extends O> map)
Factory to create the transformer.O
transform(I input)
Transforms the input to result by looking it up in aMap
.
-
-
-
Method Detail
-
mapTransformer
public static <I,O> Transformer<I,O> mapTransformer(java.util.Map<? super I,? extends O> map)
Factory to create the transformer.If the map is null, a transformer that always returns null is returned.
- Type Parameters:
I
- the input typeO
- the output type- 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 aMap
.- Specified by:
transform
in interfaceTransformer<I,O>
- Parameters:
input
- the input object to transform- Returns:
- the transformed result
-
-