public class Enums
extends java.lang.Object
Constructor and Description |
---|
Enums() |
Modifier and Type | Method and Description |
---|---|
static void |
checkAllEnumeratedIgnoreCase(java.lang.Class<? extends java.lang.Enum<?>> type,
java.lang.String... explicitValues)
as
checkAllEnumeratedIgnoreCase(String, Enum[], String...) using the same default strategy
that valueOfIgnoreCase(Class, String) applies |
static void |
checkAllEnumeratedIgnoreCase(java.lang.String contextMessage,
java.lang.Enum<?>[] enumValues,
java.lang.String... explicitValues)
checks that all accepted enum values are represented by the given set of explicit values
|
static com.google.common.base.Function<java.lang.Enum<?>,java.lang.String> |
enumValueNameFunction()
Deprecated.
since 0.7.0 use
nameFunction() to avoid inner class |
static <T extends java.lang.Enum<?>> |
fromStringFunction(java.lang.Class<T> type)
returns a function which given a string, produces an enum of the given type or null
|
static com.google.common.base.Function<java.lang.Enum<?>,java.lang.String> |
nameFunction()
returns a function which given an enum, returns its
name() function |
static <T extends java.lang.Enum<?>> |
valueOfIgnoreCase(java.lang.Class<T> type,
java.lang.String givenValue)
as
valueOfIgnoreCase(String, Enum[], String) for all values of the given enum and using the enum type as the message |
static <T extends java.lang.Enum<?>> |
valueOfIgnoreCase(java.lang.String contextMessage,
T[] enumValues,
java.lang.String givenValue)
attempts to match the givenValue against the given enum values, first looking for exact matches (against name and toString),
then matching ignoring case,
then matching with
CaseFormat.UPPER_UNDERSCORE converted to CaseFormat.LOWER_CAMEL ,
then matching with CaseFormat.LOWER_CAMEL converted to CaseFormat.UPPER_UNDERSCORE
(including case insensitive matches for the final two) |
@Deprecated public static com.google.common.base.Function<java.lang.Enum<?>,java.lang.String> enumValueNameFunction()
nameFunction()
to avoid inner classname()
functionpublic static com.google.common.base.Function<java.lang.Enum<?>,java.lang.String> nameFunction()
name()
functionpublic static <T extends java.lang.Enum<?>> com.google.common.base.Function<java.lang.String,T> fromStringFunction(java.lang.Class<T> type)
public static void checkAllEnumeratedIgnoreCase(java.lang.Class<? extends java.lang.Enum<?>> type, java.lang.String... explicitValues)
checkAllEnumeratedIgnoreCase(String, Enum[], String...)
using the same default strategy
that valueOfIgnoreCase(Class, String)
appliespublic static void checkAllEnumeratedIgnoreCase(java.lang.String contextMessage, java.lang.Enum<?>[] enumValues, java.lang.String... explicitValues)
public static <T extends java.lang.Enum<?>> Maybe<T> valueOfIgnoreCase(java.lang.Class<T> type, java.lang.String givenValue)
valueOfIgnoreCase(String, Enum[], String)
for all values of the given enum and using the enum type as the messagepublic static <T extends java.lang.Enum<?>> Maybe<T> valueOfIgnoreCase(java.lang.String contextMessage, T[] enumValues, java.lang.String givenValue)
CaseFormat.UPPER_UNDERSCORE
converted to CaseFormat.LOWER_CAMEL
,
then matching with CaseFormat.LOWER_CAMEL
converted to CaseFormat.UPPER_UNDERSCORE
(including case insensitive matches for the final two)