public final class EnumUtil extends Object implements Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
EnumUtil.EnumMapper<T extends EnumUtil.IEnumIntValue>
Helper class for getting enumeration constants based on integer value.
Uses map for mapping enumeration constants to specified integer value which results in O(1) complexity. |
static interface |
EnumUtil.IEnumIntValue
Enumeration which are to be handled using EnumUtil methods must implement this interface.
|
| Constructor and Description |
|---|
EnumUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends EnumUtil.IEnumIntValue> |
enumFor(Class<T> enumClass,
int i)
Returns enumeration constant which is associated with specified integer value.
Complexity of this method is O(n). |
static <T extends EnumUtil.IEnumIntValue> |
enumMapper(Class<T> enumClass)
Returns fast enumeration constant mapper object associated with specific enumeration.
If enumeration contains lots of enumeration constants, enumFor(Class, int) can become a performance issue.To get O(1) performace EnumUtil.EnumMapper should be used which can return enumeration constant for specified value in constant time. |
protected static <T extends EnumUtil.IEnumIntValue> |
getEnumConstants(Class<T> enumClass)
Returns enumerations constants defined in specified enumeration class.
|
static <T extends EnumUtil.IEnumIntValue> |
valueFor(T enumValue)
Returns integer value for specified enumeration element.
This method is implement for convenience only - same value can be acquired directly from enumeration constant using EnumUtil.IEnumIntValue.getValue(). |
public static <T extends EnumUtil.IEnumIntValue> int valueFor(T enumValue)
EnumUtil.IEnumIntValue.getValue().T - enumeration class which must implement EnumUtil.IEnumIntValueenumValue - enumeration constant for which to get associated integer valuepublic static <T extends EnumUtil.IEnumIntValue> T enumFor(Class<T> enumClass, int i) throws IllegalArgumentException
T - Type of enumerationenumClass - enumeration classi - value associated to enumeration constantIllegalArgumentException - if specified class is not enumeration classprotected static <T extends EnumUtil.IEnumIntValue> T[] getEnumConstants(Class<T> enumClass) throws IllegalArgumentException
T - type of enumerationenumClass - enumeration classIllegalArgumentException - if specified class is not enumeration classpublic static <T extends EnumUtil.IEnumIntValue> EnumUtil.EnumMapper<T> enumMapper(Class<T> enumClass)
enumFor(Class, int) can become a performance issue.EnumUtil.EnumMapper should be used which can return enumeration constant for specified value in constant time.
Copyright © 2014. All rights reserved.