Class MapTransformer<T,R>
java.lang.Object
org.apache.commons.collections4.functors.MapTransformer<T,R>
- Type Parameters:
T- the type of the input to the function.R- the type of the result of the function.
- All Implemented Interfaces:
Serializable,Function<T,,R> Transformer<T,R>
Transformer implementation that returns the value held in a specified map
using the input parameter as a key.
- Since:
- 3.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe map of data to lookup inprivate static final longSerial version UID -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateMapTransformer(Map<? super T, ? extends R> map) Constructor that performs no validation. -
Method Summary
Modifier and TypeMethodDescriptiongetMap()Gets the map to lookup in.static <I,O> Transformer <I, O> mapTransformer(Map<? super I, ? extends O> map) Creates the transformer.Transforms the input to result by looking it up in aMap.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.collections4.Transformer
apply
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial version UID- See Also:
-
iMap
The map of data to lookup in
-
-
Constructor Details
-
MapTransformer
Constructor that performs no validation. UsemapTransformerif you want that.- Parameters:
map- the map to use for lookup, not cloned
-
-
Method Details
-
mapTransformer
Creates 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
-
getMap
Gets the map to lookup in.- Returns:
- the map
- Since:
- 3.1
-
transform
Transforms the input to result by looking it up in aMap.- Specified by:
transformin interfaceTransformer<T,R> - Parameters:
input- the input object to transform- Returns:
- the transformed result
-