Class MapTransformer

  • All Implemented Interfaces:
    java.io.Serializable, Transformer

    public final class MapTransformer
    extends java.lang.Object
    implements Transformer, java.io.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: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map iMap
      The map of data to lookup in
      private static long serialVersionUID
      Serial version UID
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MapTransformer​(java.util.Map map)
      Constructor that performs no validation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Transformer getInstance​(java.util.Map map)
      Factory to create the transformer.
      java.util.Map getMap()
      Gets the map to lookup in.
      java.lang.Object transform​(java.lang.Object 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
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Serial version UID
        See Also:
        Constant Field Values
      • iMap

        private final java.util.Map iMap
        The map of data to lookup in
    • Constructor Detail

      • MapTransformer

        private MapTransformer​(java.util.Map map)
        Constructor that performs no validation. Use getInstance if you want that.
        Parameters:
        map - the map to use for lookup, not cloned
    • Method Detail

      • getInstance

        public static Transformer getInstance​(java.util.Map 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 java.lang.Object transform​(java.lang.Object input)
        Transforms the input to result by looking it up in a Map.
        Specified by:
        transform in interface Transformer
        Parameters:
        input - the input object to transform
        Returns:
        the transformed result
      • getMap

        public java.util.Map getMap()
        Gets the map to lookup in.
        Returns:
        the map
        Since:
        Commons Collections 3.1