Class 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:
    java.io.Serializable, java.util.function.Function<T,​R>, Transformer<T,​R>

    public final class MapTransformer<T,​R>
    extends java.lang.Object
    implements Transformer<T,​R>, 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 T,​? extends R> getMap()
      Gets the map to lookup in.
      static <I,​O>
      Transformer<I,​O>
      mapTransformer​(java.util.Map<? super I,​? extends O> map)
      Creates the transformer.
      R transform​(T 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
      • Methods inherited from interface java.util.function.Function

        andThen, compose
      • Methods inherited from interface org.apache.commons.collections4.Transformer

        apply
    • Method Detail

      • mapTransformer

        public static <I,​O> Transformer<I,​O> mapTransformer​(java.util.Map<? super I,​? extends O> map)
        Creates the transformer.

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

        Type Parameters:
        I - the input type
        O - the output type
        Parameters:
        map - the map, not cloned
        Returns:
        the transformer
      • getMap

        public java.util.Map<? super T,​? extends RgetMap()
        Gets the map to lookup in.
        Returns:
        the map
        Since:
        3.1
      • transform

        public R transform​(T input)
        Transforms the input to result by looking it up in a Map.
        Specified by:
        transform in interface Transformer<T,​R>
        Parameters:
        input - the input object to transform
        Returns:
        the transformed result