Class MapMapping

  • All Implemented Interfaces:
    Mapping
    Direct Known Subclasses:
    ToDoubleMapMapping, ToIntMapMapping

    public abstract class MapMapping
    extends java.lang.Object
    implements Mapping
    A Mapping that is based on a Map. The domain of the Mapping is the set of keys in the Map. MapMappings are immutable in the sense that the underlying Map cannot be changed (although the keys and values associated with the Map can be changed).
    Since:
    Ptolemy II 4.0
    Version:
    $Id$
    Author:
    Shuvra S. Bhattacharyya
    Pt.AcceptedRating:
    Red (ssb)
    Pt.ProposedRating:
    Red (ssb)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map _map
      The Map on which this Mapping is based.
    • Constructor Summary

      Constructors 
      Constructor Description
      MapMapping​(java.util.Map map)
      Construct a MapMapping from a given Map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)
      Return true if the given object is of the same Class and based on the same Map as this one.
      int hashCode()
      Return the hash code of this MapMapping.
      boolean inDomain​(java.lang.Object object)
      Return true if the given object is a key in the Map that is associated with this mapping.
      java.lang.String toString()
      Return a string representation of this MapMapping.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _map

        protected java.util.Map _map
        The Map on which this Mapping is based.
    • Constructor Detail

      • MapMapping

        public MapMapping​(java.util.Map map)
        Construct a MapMapping from a given Map. Modifications to the argument Map after construction of this mapping will be reflected in the Mapping.
        Parameters:
        map - The given map.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object object)
        Return true if the given object is of the same Class and based on the same Map as this one.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - The given object.
        Returns:
        True if the given object is of the same class and based on the same Map as this one.
      • hashCode

        public int hashCode()
        Return the hash code of this MapMapping. The hash code is simply that of the Map that this Mapping is based on.
        Overrides:
        hashCode in class java.lang.Object
      • inDomain

        public boolean inDomain​(java.lang.Object object)
        Return true if the given object is a key in the Map that is associated with this mapping.
        Specified by:
        inDomain in interface Mapping
        Parameters:
        object - The given object.
        Returns:
        True if the given object is a key in the Map that is associated with this mapping.
      • toString

        public java.lang.String toString()
        Return a string representation of this MapMapping. The string representation is the class name, followed by a delimiting string, followed by a string representation of the underlying Map.
        Overrides:
        toString in class java.lang.Object