|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.gjt.rec.util.Enum
Base class implementing all Enum features.
This implementation of Enum relies on the only instances of an Enum being
declared in the static initializer of their class, so that all instances are
instantiated by the time the class is loaded. An example of this reliance
can be seen in the lack of synchronization in the readResolve()
method.
NOTE: This class requires JDK 1.2 / Java 2 to work properly. It is recommended that you compile it with the JDK 1.2 option -target 1.2 to prevent its accidental use in Java 1.1 environments.
A subclass need only have a private constructor passing this class the distinct id for each declared enum instance and the public static final declarations for the enums.
This class is not implemented to allow aliasing of multiple Enum instances to the same id value.
Field Summary | |
static String |
REVISION
|
Constructor Summary | |
protected |
Enum(String uniqueId)
Construct an instance and put it in an instance dictionary that is separate for each subclass of Enum. |
Method Summary | |
int |
compareTo(Object obj)
|
boolean |
equals(Object obj)
Uses reference equality to compare objects because all instances are resolved to the declared instances even after deserialization. |
String |
getId()
|
int |
hashCode()
This method is overridden to improve the performance of hash maps. |
protected static List |
instanceList(Class cls)
|
protected Object |
readResolve()
Resolves this instance to one of the unique instances in the instance dictionary for this class by using the id as deserialized into this object. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String REVISION
Constructor Detail |
protected Enum(String uniqueId) throws DuplicateEnumIdException
DuplicateEnumIdException
- If another Enum of the same class has
already been declared with the same
id.Method Detail |
protected static List instanceList(Class cls)
public String getId()
public int compareTo(Object obj)
compareTo
in interface Comparable
protected final Object readResolve() throws NonExistentEnumException
NonExistentEnumException
- If the instance called (id) cannot be
found in the instance dictionary for
this object's class.public final int hashCode()
equals(Object)
method uses reference equality.
hashCode
in class Object
public final boolean equals(Object obj)
equals
in class Object
public final String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |