Methods Summary |
---|
protected final java.lang.Object | clone(){@code Enum} objects are singletons, they may not be cloned. This method
always throws a {@code CloneNotSupportedException}.
// KA004=Enums may not be cloned
throw new CloneNotSupportedException(Msg.getString("KA004")); //$NON-NLS-1$
|
public final int | compareTo(E o)Compares this object to the specified enum object to determine their
relative order. This method compares the object's ordinal values, that
is, their position in the enum declaration.
return ordinal - o.ordinal;
|
public final boolean | equals(java.lang.Object other)Compares this object with the specified object and indicates if they are
equal. In order to be equal, {@code object} must be identical to this
enum constant.
return this == other;
|
public final java.lang.Class | getDeclaringClass()Returns the enum constant's declaring class.
Class<?> myClass = getClass();
Class<?> mySuperClass = myClass.getSuperclass();
if (Enum.class == mySuperClass) {
return (Class<E>)myClass;
}
return (Class<E>)mySuperClass;
|
static T[] | getValues(java.lang.Class enumType)
try {
Method values = AccessController
.doPrivileged(new PrivilegedExceptionAction<Method>() {
public Method run() throws Exception {
Method valsMethod = enumType.getMethod("values", //$NON-NLS-1$
(Class[]) null);
valsMethod.setAccessible(true);
return valsMethod;
}
});
return (T[]) values.invoke(enumType, (Object[])null);
} catch (Exception e) {
return null;
}
|
public final int | hashCode()
return ordinal + (name == null ? 0 : name.hashCode());
|
public final java.lang.String | name()Returns the name of this enum constant. The name is the field as it
appears in the {@code enum} declaration.
return name;
|
public final int | ordinal()Returns the position of the enum constant in the declaration. The first
constant has an ordinal value of zero.
return ordinal;
|
public java.lang.String | toString()Returns a string containing a concise, human-readable description of this
object. In this case, the enum constant's name is returned.
return name;
|
public static T | valueOf(java.lang.Class enumType, java.lang.String name)Returns the constant with the specified name of the specified enum type.
if ((enumType == null) || (name == null)) {
// KA001=Argument must not be null
throw new NullPointerException(Msg.getString("KA001")); //$NON-NLS-1$
}
// BEGIN android-changed
enumType.checkPublicMemberAccess();
T result = enumType.getClassCache().getEnumValue(name);
if (result == null) {
if (!enumType.isEnum()) {
// KA005={0} is not an enum type
throw new IllegalArgumentException(Msg.getString("KA005", enumType)); //$NON-NLS-1$
} else {
// KA006={0} is not a constant in the enum type {1}
throw new IllegalArgumentException(Msg.getString("KA006", name, //$NON-NLS-1$
enumType));
}
}
return result;
// END android-changed
|