Mike Simmons wrote:Yes, Jon, your original post made it fairly clear you already know about the ordinal() method. But there is another method that you need, which will help address the problem you asked about, to avoid typing all those names. That's what I was pointing you towards.
The syntax looks more gory, I'm not sure how to translate it to shorter code...
"valueOf
public static <T extends Enum<T>> T valueOf(Class<T> enumType,
String name)
Returns the enum constant of the specified enum type with the specified name. The name must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Parameters:
enumType - the Class object of the enum type from which to return a constant
name - the name of the constant to return
Returns:
the enum constant of the specified enum type with the specified name
Throws:
IllegalArgumentException - if the specified enum type has no constant with the specified name, or the specified class object does not represent an enum type
NullPointerException - if enumType or name is null
Since:
1.5"
http://download.oracle.com/javase/6/docs/api