public abstract class Enum extends Object implements Comparable, Serializable
This class is equivalent to java.lang.Enum
and is moved (refactored) to the java.lang
system
package for applications targetting the J2SE 5.0+ run-time.
This is a clean-room implementation of the Enum base class.
Modifier | Constructor and Description |
---|---|
protected |
Enum(String name,
int ordinal)
Enum's base constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Object that)
Compares the position of two enum from the same enumeration.
|
boolean |
equals(Object that)
Indicates if two enums are equals.
|
Class |
getDeclaringClass()
Returns this enum's class.
|
int |
hashCode()
Returns the enums' hashcode.
|
String |
name()
Returns the name of this enum.
|
int |
ordinal()
Returns the position of this enum in the enumeration (starting
at
0 ). |
String |
toString()
Returns the
String representation of this enum. |
static Enum |
valueOf(Class enumType,
String name)
Returns the enum from the specified enum's class with the specified
name.
|
protected Enum(String name, int ordinal)
name
- the enum's name.ordinal
- the enum's position.public final String name()
public final int ordinal()
0
).public String toString()
String
representation of this enum.public final boolean equals(Object that)
public final int hashCode()
public final int compareTo(Object that)
compareTo
in interface Comparable
that
- the enum to be compared with.ClassCastException
- if both enum do not belong to the same
enumeration.public final Class getDeclaringClass()
this.getClass()
public static Enum valueOf(Class enumType, String name)
enumType
- the enum's declaring class.name
- the name of the enum to return.IllegalArgumentException
- if the enum does not exist.Copyright © 2005–2014 Javolution. All rights reserved.