Package ptolemy.graph.mapping
Class ToIntMapMapping
- java.lang.Object
-
- ptolemy.graph.mapping.MapMapping
-
- ptolemy.graph.mapping.ToIntMapMapping
-
- All Implemented Interfaces:
Mapping
,ToIntMapping
public class ToIntMapMapping extends MapMapping implements ToIntMapping
A ToIntMapping that is based on a Map. The values in the Map must be instances of Integer. ToIntMapMappings 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 inherited from class ptolemy.graph.mapping.MapMapping
_map
-
-
Constructor Summary
Constructors Constructor Description ToIntMapMapping(java.util.Map map)
Construct a ToIntMapMapping from a given map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
inDomain(java.lang.Object object)
Return true if the given object is in the domain of this Mapping.int
toInt(java.lang.Object object)
Return the int value that is associated with given object under this mapping.java.lang.Object
toObject(java.lang.Object object)
Return the object associated with the given object in the mapping.-
Methods inherited from class ptolemy.graph.mapping.MapMapping
equals, hashCode, toString
-
-
-
-
Constructor Detail
-
ToIntMapMapping
public ToIntMapMapping(java.util.Map map)
Construct a ToIntMapMapping from a given map. The values in the must be instances of Integer; otherwise, unpredictable behavior may result. Modifications to the argument Map after construction of this mapping will be reflected in the mapping. The Map modifications must follow the restriction that all added values to the Map must be instances of Integer.- Parameters:
map
- The given map.
-
-
Method Detail
-
inDomain
public boolean inDomain(java.lang.Object object)
Return true if the given object is in the domain of this Mapping. More precisely, return true if the given object is a valid argument totoInt(Object)
, which means that the object is a key in the Map that is associated with this Mapping and the value in the Map is an instance of Integer.- Specified by:
inDomain
in interfaceMapping
- Overrides:
inDomain
in classMapMapping
- Parameters:
object
- The given object.- Returns:
- True if the given object is in the domain of this Mapping.
-
toInt
public int toInt(java.lang.Object object)
Return the int value that is associated with given object under this mapping. For efficiency, no error checking is performed on the argument, and consequently, a runtime exception may result as noted below. To perform argument validity checking before mapping an object, useMapping.inDomain(Object)
.- Specified by:
toInt
in interfaceToIntMapping
- Parameters:
object
- The given object.- Returns:
- The int value that is associated with given object under this mapping.
- Throws:
java.lang.RuntimeException
- If the given object is not an instance ofInteger
or if the given object is not in the domain of the mapping.
-
toObject
public java.lang.Object toObject(java.lang.Object object)
Description copied from interface:Mapping
Return the object associated with the given object in the mapping.
-
-