Package ptolemy.data.type
Class TypeConstant
- java.lang.Object
-
- ptolemy.data.type.TypeConstant
-
- All Implemented Interfaces:
InequalityTerm
public class TypeConstant extends java.lang.Object implements InequalityTerm
An InequalityTerm that encapsulates a constant type. The constant type is specified in the constructor. This class represents a constant term in an inequality constraint for type resolution.- Since:
- Ptolemy II 0.4
- Version:
- $Id$
- Author:
- Yuhong Xiong
- See Also:
InequalityTerm
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (yuhong)
-
-
Constructor Summary
Constructors Constructor Description TypeConstant(Type type)
Construct a TypeConstant.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object object)
Override to return true if the type is the same in this object as the specified object.java.lang.Object
getAssociatedObject()
Return null.java.lang.Object
getValue()
Return the constant type represented by this term.InequalityTerm[]
getVariables()
Return an array of size zero.int
hashCode()
Return the hashCode of the type.void
initialize(java.lang.Object e)
Throw an Exception since type constant cannot be initialized.boolean
isSettable()
Return false since this term represent a constant.boolean
isValueAcceptable()
Check whether the current type of this term is acceptable, and return true if it is.void
setValue(java.lang.Object e)
Throw IllegalActionException since the value of this term cannot be changed.java.lang.String
toString()
Return a string representation of this term.
-
-
-
Constructor Detail
-
TypeConstant
public TypeConstant(Type type)
Construct a TypeConstant.- Parameters:
type
- An instance of Type.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object object)
Override to return true if the type is the same in this object as the specified object.- Overrides:
equals
in classjava.lang.Object
- Parameters:
object
- The object to compare against.- Returns:
- true if the argument is equal to this argument.
-
getAssociatedObject
public java.lang.Object getAssociatedObject()
Return null.- Specified by:
getAssociatedObject
in interfaceInequalityTerm
- Returns:
- null.
-
getValue
public java.lang.Object getValue()
Return the constant type represented by this term.- Specified by:
getValue
in interfaceInequalityTerm
- Returns:
- A Type.
- See Also:
setValue(Object)
-
getVariables
public InequalityTerm[] getVariables()
Return an array of size zero.- Specified by:
getVariables
in interfaceInequalityTerm
- Returns:
- An array of InequalityTerm of size 0.
-
hashCode
public int hashCode()
Return the hashCode of the type. This ensures that if equals() returns true then the two objects return the same hashCode.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hashCode of this object.
-
initialize
public void initialize(java.lang.Object e) throws IllegalActionException
Throw an Exception since type constant cannot be initialized.- Specified by:
initialize
in interfaceInequalityTerm
- Parameters:
e
- An Object representing an element in the underlying CPO.- Throws:
IllegalActionException
- Always thrown.
-
isSettable
public boolean isSettable()
Return false since this term represent a constant.- Specified by:
isSettable
in interfaceInequalityTerm
- Returns:
- false.
-
isValueAcceptable
public boolean isValueAcceptable()
Check whether the current type of this term is acceptable, and return true if it is. A type is acceptable if it represents an instantiable object.- Specified by:
isValueAcceptable
in interfaceInequalityTerm
- Returns:
- True if the current type is acceptable.
-
setValue
public void setValue(java.lang.Object e) throws IllegalActionException
Throw IllegalActionException since the value of this term cannot be changed.- Specified by:
setValue
in interfaceInequalityTerm
- Parameters:
e
- An Object representing an element in the underlying CPO.- Throws:
IllegalActionException
- Always thrown.- See Also:
getValue()
-
toString
public java.lang.String toString()
Return a string representation of this term.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A String.
-
-