org.norecess.citkit.types
Class NameType

java.lang.Object
  extended by org.norecess.citkit.types.NameType
All Implemented Interfaces:
HobbesType, INameType

public class NameType
extends java.lang.Object
implements INameType

Data type for a named type.

Author:
Jeremy D. Frens

Constructor Summary
NameType(ISymbol symbol)
           
NameType(ISymbol symbol, HobbesType binding)
           
NameType(java.lang.String name)
           
NameType(java.lang.String name, HobbesType binding)
           
 
Method Summary
<T> T
accept(TypeVisitor<T> visitor)
           
 HobbesType actual()
          Returns the actual data type this named type represents.
 void bind(HobbesType type)
          Binds the named type to another type.
 boolean equals(java.lang.Object o)
           
 HobbesType getBinding()
          Returns the binding of this named type.
 ISymbol getSymbol()
           
 int hashCode()
           
 boolean isBound()
          Returns a boolean regarding the boundness of this named type.
 java.lang.String toShortString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NameType

public NameType(ISymbol symbol)

NameType

public NameType(ISymbol symbol,
                HobbesType binding)

NameType

public NameType(java.lang.String name)

NameType

public NameType(java.lang.String name,
                HobbesType binding)
Method Detail

getSymbol

public ISymbol getSymbol()
Specified by:
getSymbol in interface INameType

actual

public HobbesType actual()
Returns the actual data type this named type represents. This follows the chain of bindings to a basic type (e.g., IntegerTypeor RecordType).

Specified by:
actual in interface HobbesType
Returns:
the actual data type.
Throws:
java.lang.NullPointerException - is the named type is unbound.
See Also:
bind(HobbesType), getBinding()

bind

public void bind(HobbesType type)
Binds the named type to another type. actual()will recursively call itself on this binding until it reaches a basic type.

Specified by:
bind in interface INameType
Parameters:
type - the real type of this named type.
See Also:
actual(), getBinding()

getBinding

public HobbesType getBinding()
Returns the binding of this named type. Unlike actual(), this method returns just the binding of this named type; it does not follow any chain of bindings to find a basic type.

Specified by:
getBinding in interface INameType
See Also:
actual(), bind(HobbesType)

isBound

public boolean isBound()
Returns a boolean regarding the boundness of this named type.

Specified by:
isBound in interface HobbesType
Returns:
true if this named type is bound, false otherwise.

accept

public <T> T accept(TypeVisitor<T> visitor)
Specified by:
accept in interface HobbesType

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toShortString

public java.lang.String toShortString()
Specified by:
toShortString in interface HobbesType