Package ptolemy.graph.mapping
Class ToDoubleMapMapping
- java.lang.Object
-
- ptolemy.graph.mapping.MapMapping
-
- ptolemy.graph.mapping.ToDoubleMapMapping
-
- All Implemented Interfaces:
Mapping
,ToDoubleMapping
public class ToDoubleMapMapping extends MapMapping implements ToDoubleMapping
A ToDoubleMapping that is based on a Map. The values in the Map must be instances of Double. ToDoubleMapMappings 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 ToDoubleMapMapping(java.util.Map map)
Construct a ToDoubleMapMapping 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.double
toDouble(java.lang.Object object)
Return the double 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.-
Methods inherited from class ptolemy.graph.mapping.MapMapping
equals, hashCode, toString
-
-
-
-
Constructor Detail
-
ToDoubleMapMapping
public ToDoubleMapMapping(java.util.Map map)
Construct a ToDoubleMapMapping from a given map. The values in the map must be instances of Double; 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 Double.- 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 totoDouble(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 Double.- 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.
-
toDouble
public double toDouble(java.lang.Object object)
Return the double 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, useinDomain(Object)
.- Specified by:
toDouble
in interfaceToDoubleMapping
- Parameters:
object
- The given object.- Returns:
- The double value that is associated with given object under this mapping.
- Throws:
java.lang.RuntimeException
- If the given object is not an instance ofDouble
or if the given object is not in the domain of the mapping.
-
-