com.glaivestone.javax.lang
Class EnumerationType

java.lang.Object
  |
  +--com.glaivestone.javax.lang.ConstantType
        |
        +--com.glaivestone.javax.lang.EnumerationType
All Implemented Interfaces:
java.lang.Comparable

public class EnumerationType
extends ConstantType
implements java.lang.Comparable

EnumerationType is the abstract superclass for implementing constant types which allow clients to enumerate the defined constants in the enumeration.

Enumerated values are Comparable. The default sort order for an enumeration is in increasing order by ordinal value.

Subclass Responsibilities

Ordinal values for an enumeration type are generally expected to start at 0 and increment by 1 for each constant defined in the enumeration. It is the responsibility of concrete subclasses to provide a suitable ordinal allocation mechanism. Enumeration classes will usually provide for strict control over allocation by using private constructors; they may be declared final to prevent subclassing from affecting the enumeration.

Concrete subclasses are responsble for implementing the following static methods:

     size() - returns the int number of values in the enumeration
     iterator() - returns an Iterator on the values in the enumeration
 

Author:
Deb Lewis

Field Summary
 
Fields inherited from class com.glaivestone.javax.lang.ConstantType
name, ord
 
Method Summary
 int compareTo(java.lang.Object aValue)
          Compares this object with the specified object for order.
static java.util.Iterator getIterator(java.lang.Class anEnumerationClass)
          Answer an iterator over the enumeration constants of the specified type.
static int getSize(java.lang.Class anEnumerationClass)
          Answer the number of enumeration constants of the specified type.
static java.util.List getValues(java.lang.Class anEnumerationClass)
          Returns a list of the enumeration constants of the specified type.
static void validateEnumerationType(java.lang.Class aClass)
          Verify that the specified class is an enumeration type.
 
Methods inherited from class com.glaivestone.javax.lang.ConstantType
getConstant, getConstant, intValue, toConstantName, toDescriptionString, toIdentificationString, toQualifiedConstantName, toSimpleConstantName, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getIterator

public static java.util.Iterator getIterator(java.lang.Class anEnumerationClass)
Answer an iterator over the enumeration constants of the specified type.


getSize

public static int getSize(java.lang.Class anEnumerationClass)
Answer the number of enumeration constants of the specified type.


getValues

public static java.util.List getValues(java.lang.Class anEnumerationClass)
Returns a list of the enumeration constants of the specified type.

Typically ordered in ascending ordinal value.


validateEnumerationType

public static void validateEnumerationType(java.lang.Class aClass)
Verify that the specified class is an enumeration type.

Throws:
java.lang.IllegalArgumentException - not an enumeration type

compareTo

public int compareTo(java.lang.Object aValue)
Compares this object with the specified object for order. Enumeration constants sort in ascending order by ordinal value.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
aValue - the value to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this Object.
See Also:
Comparable.compareTo(java.lang.Object)

GFL 1.1 API