public class IntEnum extends Enum
A type safe enumeration object that is keyed by an Int value for switch statements and storage in DBs.
Used for indicating distinct states in a generic manner where each enum should have an associated int value. The given int should be unique for each enum value as hashCode and equals depends solely on the int value given. Most child classes should extend IntEnum and create static instances.
Modifier | Constructor and Description |
---|---|
protected |
IntEnum(String name,
int val) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object object) |
protected static IntEnum |
getEnumFromInt(Class enumClass,
int value)
Obtain the enum associated with the given value.
|
int |
getValue()
Returns the int value associated with the enum.
|
int |
hashCode() |
protected static void |
register(IntEnum enumeration)
Checks in an enum for use in the getEnumFromInt() method.
|
String |
toString() |
protected static Hashtable enumTypes
protected IntEnum(String name, int val)
public int getValue()
protected static void register(IntEnum enumeration)
Checks in an enum for use in the getEnumFromInt() method.
enumeration
- The enum to be registeredprotected static IntEnum getEnumFromInt(Class enumClass, int value)
Obtain the enum associated with the given value.
Values must be registered earlier using the register() method.
value
- the value to lookup the enum forCopyright © 2003-2008 Jive Software.