public class EnumUtils
extends java.lang.Object
EnumClass implementations to convert identifiers to enum values.| Constructor and Description |
|---|
EnumUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends java.lang.Enum<T> & EnumClass<V>,V> |
fromId(java.lang.Class<T> e,
V id)
Returns an enum value for the given id.
|
static <T extends java.lang.Enum<T> & EnumClass<V>,V> |
fromId(java.lang.Class<T> e,
V id,
T defaultValue)
Returns an enum value for the given id.
|
static <T extends java.lang.Enum<T> & EnumClass<V>,V> |
fromIdSafe(java.lang.Class<T> e,
V id,
T defaultValue)
Returns an enum value for the given id, or the default value if null is passed or there are no enum values with
the given id.
|
@Nullable public static <T extends java.lang.Enum<T> & EnumClass<V>,V> T fromId(java.lang.Class<T> e, V id)
e - enum classid - idjava.lang.IllegalArgumentException - if there are no enum values with the given idpublic static <T extends java.lang.Enum<T> & EnumClass<V>,V> T fromId(java.lang.Class<T> e, V id, T defaultValue)
e - enum classid - iddefaultValue - the value to return if null is passed as idjava.lang.IllegalArgumentException - if there are no enum values with the given idpublic static <T extends java.lang.Enum<T> & EnumClass<V>,V> T fromIdSafe(java.lang.Class<T> e, V id, T defaultValue)
e - enum classid - iddefaultValue - the value to return if null is passed as id or if there are no enum values with the given id