Class 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.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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 class java.lang.Object
        Parameters:
        object - The object to compare against.
        Returns:
        true if the argument is equal to this argument.
      • getValue

        public java.lang.Object getValue()
        Return the constant type represented by this term.
        Specified by:
        getValue in interface InequalityTerm
        Returns:
        A Type.
        See Also:
        setValue(Object)
      • 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 class java.lang.Object
        Returns:
        The hashCode of this object.
      • isSettable

        public boolean isSettable()
        Return false since this term represent a constant.
        Specified by:
        isSettable in interface InequalityTerm
        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 interface InequalityTerm
        Returns:
        True if the current type is acceptable.
      • toString

        public java.lang.String toString()
        Return a string representation of this term.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A String.