org.vizzini.util
Class AbstractEnumeratedType

java.lang.Object
  extended by org.vizzini.util.AbstractEnumeratedType
All Implemented Interfaces:
Comparable, IEnumeratedType
Direct Known Subclasses:
ArgumentType, Arrangement, ConnectiveType, CrossoverType, DefaultEnumeratedType, Markings, OperatorType, SentenceType

public abstract class AbstractEnumeratedType
extends Object
implements IEnumeratedType

Provides base functionality for enumerated types. Subclasses should set the _ordinal, presumably from a static counter.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson

Constructor Summary
protected AbstractEnumeratedType(String name)
          Construct this object.
protected AbstractEnumeratedType(String name, String displayName)
          Construct this object.
 
Method Summary
 int compareTo(Object another)
          Compare this object to the given object.
 boolean equals(Object object)
          Return true if the given object is equal to this.
 String getDisplayName()
           
 String getName()
          Return the name of this type.
 int hashCode()
          Return the hash code.
 int intValue()
          Return the integer value of this type.
protected  void setOrdinal(int ordinal)
          Set the ordinal.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractEnumeratedType

protected AbstractEnumeratedType(String name)
Construct this object. By making the constructor protected, new types can only be added by subclasses.

Parameters:
name - The name.
Since:
v0.1

AbstractEnumeratedType

protected AbstractEnumeratedType(String name,
                                 String displayName)
Construct this object. By making the constructor protected, new types can only be added by subclasses.

Parameters:
name - Name.
displayName - Display name.
Since:
v0.1
Method Detail

compareTo

public int compareTo(Object another)
Compare this object to the given object.

Specified by:
compareTo in interface Comparable
Since:
v0.1

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Specified by:
equals in interface IEnumeratedType
Overrides:
equals in class Object
Parameters:
object - The object to compare.
Since:
v0.1

getDisplayName

public String getDisplayName()
Returns:
Return displayName.
Since:
v0.3

getName

public String getName()
Return the name of this type.

Specified by:
getName in interface IEnumeratedType
Since:
v0.1

hashCode

public int hashCode()
Return the hash code.

Specified by:
hashCode in interface IEnumeratedType
Overrides:
hashCode in class Object
Since:
v0.1

intValue

public int intValue()
Return the integer value of this type.

Specified by:
intValue in interface IEnumeratedType
Since:
v0.1

toString

public String toString()
Return a string representation of this object.

Specified by:
toString in interface IEnumeratedType
Overrides:
toString in class Object
Since:
v0.1

setOrdinal

protected void setOrdinal(int ordinal)
Set the ordinal. This method should only be called from the sublclass' constructor.

Since:
v0.1


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02