Package com.saperion.util
Class EnumConstant
- java.lang.Object
-
- com.saperion.util.EnumConstant
-
public final class EnumConstant extends java.lang.Object
Utility class that can be used to safely retrieve enum constants by their position in the value-array.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends java.lang.Enum<?>>
Tget(java.lang.Class<T> clazz, int position, T defaultValue)
Retrieves the enum-constant at the specified position in the value-array of the Enum defined by the specified class.
-
-
-
Method Detail
-
get
public static <T extends java.lang.Enum<?>> T get(java.lang.Class<T> clazz, int position, T defaultValue)
Retrieves the enum-constant at the specified position in the value-array of the Enum defined by the specified class. If the class is not an Enum, or if there is no constant at the specified position in the array, the default value will be returned.- Type Parameters:
T
- the type of the Enum- Parameters:
clazz
- Class defining the Enum to read fromposition
- the position of the constant in the value-arraydefaultValue
- the default value to return if no constant was found- Returns:
- enum constant or default value, if no constant was found
-
-