List of utility methods to do Enum from Ordinal
E | fromOrdinal(Class from Ordinal E[] enumArray = enumClass.getEnumConstants();
return enumArray[ordinal];
|
T | fromOrdinal(Class Get the enum value from its ordinal value Enum<T>[] values = (enumClass).getEnumConstants(); if (value > values.length - 1 || value < 0) { throw new IllegalArgumentException( "Wrong value provided for the enum " + enumClass + " : " + value + "!"); return (T) values[value]; |
E | fromOrdinal(E[] values, int ordinal) from Ordinal return ordinal >= 0 && ordinal < values.length ? values[ordinal] : values[0];
|