Top Description Fields Constructors Methods
org.apache.commons.collections4.functors

public final Class MapTransformer<I, O>

extends Object
implements Transformer<I, O>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.collections4.Transformer
Imports
java.io.Serializable, java.util.Map, org.apache.commons.collections4.Transformer

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

Field Summary

Modifier and TypeField and Description
private final Map<? super I, ? extends O>
iMap

The map of data to lookup in

private static final long
serialVersionUID

Serial version UID

Constructor Summary

AccessConstructor and Description
private
MapTransformer(final Map<? super I, ? extends O>
the map to use for lookup, not cloned
map
)

Constructor that performs no validation.

Method Summary

Modifier and TypeMethod and Description
public Map<? super I, ? extends O>

Returns:

the map
getMap
()

Gets the map to lookup in.

public static <
the input type
I
,
the output type
O
>
Transformer<I, O>

Returns:

the transformer
mapTransformer
(final Map<? super I, ? extends O>
the map, not cloned
map
)

Factory to create the transformer.

public O

Returns:

the transformed result
transform
(final I
the input object to transform
input
)

Implements org.apache.commons.collections4.Transformer.transform.

Transforms the input to result by looking it up in a Map.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iMapback to summary
private final Map<? super I, ? extends O> iMap

The map of data to lookup in

serialVersionUIDback to summary
private static final long serialVersionUID

Serial version UID

Constructor Detail

MapTransformerback to summary
private MapTransformer(final Map<? super I, ? extends O> map)

Constructor that performs no validation. Use mapTransformer if you want that.

Parameters
map:Map<? super I, ? extends O>

the map to use for lookup, not cloned

Method Detail

getMapback to summary
public Map<? super I, ? extends O> getMap()

Gets the map to lookup in.

Returns:Map<? super I, ? extends O>

the map

Since
3.1
mapTransformerback to summary
public static <I, O> Transformer<I, O> mapTransformer(final Map<? super I, ? extends O> map)

Factory to create the transformer.

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

Parameters
<I>
the input type
<O>
the output type
map:Map<? super I, ? extends O>

the map, not cloned

Returns:Transformer<I, O>

the transformer

transformback to summary
public O transform(final I input)

Implements org.apache.commons.collections4.Transformer.transform.

Transforms the input to result by looking it up in a Map.

Parameters
input:I

the input object to transform

Returns:O

the transformed result

Annotations
@Override