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 booleanequals(java.lang.Object object)Override to return true if the type is the same in this object as the specified object.java.lang.ObjectgetAssociatedObject()Return null.java.lang.ObjectgetValue()Return the constant type represented by this term.InequalityTerm[]getVariables()Return an array of size zero.inthashCode()Return the hashCode of the type.voidinitialize(java.lang.Object e)Throw an Exception since type constant cannot be initialized.booleanisSettable()Return false since this term represent a constant.booleanisValueAcceptable()Check whether the current type of this term is acceptable, and return true if it is.voidsetValue(java.lang.Object e)Throw IllegalActionException since the value of this term cannot be changed.java.lang.StringtoString()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:
equalsin 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:
getAssociatedObjectin interfaceInequalityTerm- Returns:
- null.
-
getValue
public java.lang.Object getValue()
Return the constant type represented by this term.- Specified by:
getValuein interfaceInequalityTerm- Returns:
- A Type.
- See Also:
setValue(Object)
-
getVariables
public InequalityTerm[] getVariables()
Return an array of size zero.- Specified by:
getVariablesin 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:
hashCodein classjava.lang.Object- Returns:
- The hashCode of this object.
-
initialize
public void initialize(java.lang.Object e) throws IllegalActionExceptionThrow an Exception since type constant cannot be initialized.- Specified by:
initializein 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:
isSettablein 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:
isValueAcceptablein interfaceInequalityTerm- Returns:
- True if the current type is acceptable.
-
setValue
public void setValue(java.lang.Object e) throws IllegalActionExceptionThrow IllegalActionException since the value of this term cannot be changed.- Specified by:
setValuein 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:
toStringin classjava.lang.Object- Returns:
- A String.
-
-