java.lang
Class Enum<E>
public
class
Enum<E extends Enum<E>>
extends Object
implements Comparable<E>, Serializable
This is the common base class of all Java language enumeration types.
Since: 1.5
Version: 1.1, 01/27/03
Author: Neal Gafter
Field Summary |
String | name
The name of this enum constant, as declared in the enum declaration.
|
int | ordinal
The ordinal of this enumeration constant (its position
in the enum declaration, where the initial constant is assigned
an ordinal of zero).
|
Method Summary |
protected Object | clone()
Throws CloneNotSupportedException. |
int | compareTo(E o)
Compares this enum with the specified object for order. |
boolean | equals(Object other)
Returns true if the specified object is equal to this
enum constant.
|
List<E> | family()
Returns an immutable list of all the enum constants in this
enum constant's enum class. |
int | hashCode()
Returns a hash code for this enum constant.
|
protected Object | readResolve()
This method ensures proper deserialization of enum constants.
|
String | toString()
Returns the name of this enum constant, as contained in the
declaration. |
protected static <E extends Enum<E>> E | valueOf(List<E> family, String name)
This helper function exists in the prototype only; it will not
appear in the final implementation. |
The name of this enum constant, as declared in the enum declaration.
Most programmers should use the toString method rather than
accessing this field.
public final transient int ordinal
The ordinal of this enumeration constant (its position
in the enum declaration, where the initial constant is assigned
an ordinal of zero).
Most programmers will have no use for this field. It is designed
for use by sophisticated enum-based data structures, such as
java.util.EnumSet and java.util.EnumMap.
protected Enum(
String name, int ordinal)
Sole constructor. Programmers cannot invoke this constructor.
It is for use by code emitted by the compiler in response to
enum class declarations.
Parameters: name - The name of this enum constant, which is the identifier
used to declare it. ordinal - The ordinal of this enumeration constant (its position
in the enum declaration, where the initial constant is assigned
an ordinal of zero).
protected final
Object clone()
Throws CloneNotSupportedException. This guarantees that enums
are never cloned, which is necessary to preserve their "singleton"
status.
Returns: (never returns)
public int compareTo(
E o)
Compares this enum with the specified object for order. Returns a
negative integer, zero, or a positive integer as this object is less
than, equal to, or greater than the specified object.
Enum constants are only comparable to other enum constants of the
same enum class. The natural order implemented by this
method is the order in which the constants are declared.
public final boolean equals(
Object other)
Returns true if the specified object is equal to this
enum constant.
Parameters: o the object to be compared for equality with this object.
Returns: true if the specified object is equal to this
enum constant.
Returns an immutable list of all the enum constants in this
enum constant's enum class. This should be abstract, but isn't
due to a bug in the generic compiler.
Returns: an immutable list of all of the enum constants in this
enum constant's enum class.
public final int hashCode()
Returns a hash code for this enum constant.
Returns: a hash code for this enum constant.
protected final
Object readResolve()
This method ensures proper deserialization of enum constants.
UNKNOWN: the canonical form of this desesrialized enum const.
Returns the name of this enum constant, as contained in the
declaration. This method may be overridden, though it typically
isn't necessary or desirable. An enum class should override this
method when a more "programmer-friendly" string form exists.
Returns: the name of this enum constant
This helper function exists in the prototype only; it will not
appear in the final implementation. It is a shortcut to help
implement Enumtype.valueOf(String).