@Immutable public final class EnumHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static EChange |
clearCache() |
static String |
getEnumID(Enum<?> aEnum)
Get the unique name of the passed enum entry.
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasID<String>> |
getFromIDCaseInsensitiveOrDefault(Class<ENUMTYPE> aClass,
String sID,
ENUMTYPE aDefault)
Get the enum value with the passed string ID case insensitive
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasID<String>> |
getFromIDCaseInsensitiveOrNull(Class<ENUMTYPE> aClass,
String sID)
Get the enum value with the passed string ID case insensitive
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasID<String>> |
getFromIDCaseInsensitiveOrThrow(Class<ENUMTYPE> aClass,
String sID)
Get the enum value with the passed string ID (case insensitive).
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasIntID> |
getFromIDOrDefault(Class<ENUMTYPE> aClass,
int nID,
ENUMTYPE aDefault)
Get the enum value with the passed ID
|
static <KEYTYPE,ENUMTYPE extends Enum<ENUMTYPE> & IHasID<KEYTYPE>> |
getFromIDOrDefault(Class<ENUMTYPE> aClass,
KEYTYPE aID,
ENUMTYPE aDefault)
Get the enum value with the passed ID
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasIntID> |
getFromIDOrNull(Class<ENUMTYPE> aClass,
int nID)
Get the enum value with the passed ID
|
static <KEYTYPE,ENUMTYPE extends Enum<ENUMTYPE> & IHasID<KEYTYPE>> |
getFromIDOrNull(Class<ENUMTYPE> aClass,
KEYTYPE aID)
Get the enum value with the passed ID
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasIntID> |
getFromIDOrThrow(Class<ENUMTYPE> aClass,
int nID)
Get the enum value with the passed ID.
|
static <KEYTYPE,ENUMTYPE extends Enum<ENUMTYPE> & IHasID<KEYTYPE>> |
getFromIDOrThrow(Class<ENUMTYPE> aClass,
KEYTYPE aID)
Get the enum value with the passed ID.
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> |
getFromNameCaseInsensitiveOrDefault(Class<ENUMTYPE> aClass,
String sName,
ENUMTYPE aDefault)
Get the enum value with the passed name case insensitive
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> |
getFromNameCaseInsensitiveOrNull(Class<ENUMTYPE> aClass,
String sName)
Get the enum value with the passed name case insensitive
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> |
getFromNameCaseInsensitiveOrThrow(Class<ENUMTYPE> aClass,
String sName)
Get the enum value with the passed name (case insensitive).
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> |
getFromNameOrDefault(Class<ENUMTYPE> aClass,
String sName,
ENUMTYPE aDefault)
Get the enum value with the passed name
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> |
getFromNameOrNull(Class<ENUMTYPE> aClass,
String sName)
Get the enum value with the passed name
|
static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> |
getFromNameOrThrow(Class<ENUMTYPE> aClass,
String sName)
Get the enum value with the passed name.
|
@Nullable public static <KEYTYPE,ENUMTYPE extends Enum<ENUMTYPE> & IHasID<KEYTYPE>> ENUMTYPE getFromIDOrNull(@Nonnull Class<ENUMTYPE> aClass, @Nullable KEYTYPE aID)
KEYTYPE - The ID typeENUMTYPE - The enum typeaClass - The enum classaID - The ID to searchnull if no enum item with the given ID is present.@Nullable public static <KEYTYPE,ENUMTYPE extends Enum<ENUMTYPE> & IHasID<KEYTYPE>> ENUMTYPE getFromIDOrDefault(@Nonnull Class<ENUMTYPE> aClass, @Nullable KEYTYPE aID, @Nullable ENUMTYPE aDefault)
KEYTYPE - The ID typeENUMTYPE - The enum typeaClass - The enum classaID - The ID to searchaDefault - The default value to be returned, if the ID was not found.@Nonnull public static <KEYTYPE,ENUMTYPE extends Enum<ENUMTYPE> & IHasID<KEYTYPE>> ENUMTYPE getFromIDOrThrow(@Nonnull Class<ENUMTYPE> aClass, @Nullable KEYTYPE aID)
IllegalArgumentException is thrown.KEYTYPE - The ID typeENUMTYPE - The enum typeaClass - The enum classaID - The ID to searchnull.IllegalArgumentException - if no enum item with the given ID is present@Nullable public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasID<String>> ENUMTYPE getFromIDCaseInsensitiveOrNull(@Nonnull Class<ENUMTYPE> aClass, @Nullable String sID)
ENUMTYPE - The enum typeaClass - The enum classsID - The ID to searchnull if no enum item with the given ID is present.@Nullable public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasID<String>> ENUMTYPE getFromIDCaseInsensitiveOrDefault(@Nonnull Class<ENUMTYPE> aClass, @Nullable String sID, @Nullable ENUMTYPE aDefault)
ENUMTYPE - The enum typeaClass - The enum classsID - The ID to searchaDefault - The default value to be returned, if the ID was not found.@Nonnull public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasID<String>> ENUMTYPE getFromIDCaseInsensitiveOrThrow(@Nonnull Class<ENUMTYPE> aClass, @Nullable String sID)
IllegalArgumentException is thrown.ENUMTYPE - The enum typeaClass - The enum classsID - The ID to searchnull.IllegalArgumentException - if no enum item with the given ID is present@Nullable public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasIntID> ENUMTYPE getFromIDOrNull(@Nonnull Class<ENUMTYPE> aClass, int nID)
ENUMTYPE - The enum typeaClass - The enum classnID - The ID to searchnull if no enum item with the given ID is present.@Nullable public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasIntID> ENUMTYPE getFromIDOrDefault(@Nonnull Class<ENUMTYPE> aClass, int nID, @Nullable ENUMTYPE aDefault)
ENUMTYPE - The enum typeaClass - The enum classnID - The ID to searchaDefault - The default value to be returned, if the ID was not found.@Nonnull public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasIntID> ENUMTYPE getFromIDOrThrow(@Nonnull Class<ENUMTYPE> aClass, int nID)
IllegalArgumentException is thrown.ENUMTYPE - The enum typeaClass - The enum classnID - The ID to searchnull.IllegalArgumentException - if no enum item with the given ID is present@Nullable public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> ENUMTYPE getFromNameOrNull(@Nonnull Class<ENUMTYPE> aClass, @Nullable String sName)
ENUMTYPE - The enum typeaClass - The enum classsName - The name to searchnull if no enum item with the given name is present.@Nullable public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> ENUMTYPE getFromNameOrDefault(@Nonnull Class<ENUMTYPE> aClass, @Nullable String sName, @Nullable ENUMTYPE aDefault)
ENUMTYPE - The enum typeaClass - The enum classsName - The name to searchaDefault - The default value to be returned, if the name was not found.@Nonnull public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> ENUMTYPE getFromNameOrThrow(@Nonnull Class<ENUMTYPE> aClass, @Nullable String sName)
IllegalArgumentException is thrown.ENUMTYPE - The enum typeaClass - The enum classsName - The name to searchnull.IllegalArgumentException - if no enum item with the given name is present@Nullable public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> ENUMTYPE getFromNameCaseInsensitiveOrNull(@Nonnull Class<ENUMTYPE> aClass, @Nullable String sName)
ENUMTYPE - The enum typeaClass - The enum classsName - The name to searchnull if no enum item with the given ID is present.@Nullable public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> ENUMTYPE getFromNameCaseInsensitiveOrDefault(@Nonnull Class<ENUMTYPE> aClass, @Nullable String sName, @Nullable ENUMTYPE aDefault)
ENUMTYPE - The enum typeaClass - The enum classsName - The name to searchaDefault - The default value to be returned, if the name was not found.@Nonnull public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> ENUMTYPE getFromNameCaseInsensitiveOrThrow(@Nonnull Class<ENUMTYPE> aClass, @Nullable String sName)
IllegalArgumentException is thrown.ENUMTYPE - The enum typeaClass - The enum classsName - The name to searchnull.IllegalArgumentException - if no enum item with the given name is present@Nonnull public static String getEnumID(@Nonnull Enum<?> aEnum)
aEnum - The enum to use. May not be null.null.Copyright © 2014–2016 Philip Helger. All rights reserved.