public final class EnumUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
isFlagSet(int value,
java.lang.Enum<?> e)
Checks whether the int-based "bit flags" representation of the given enumeration value is present in the given value.
|
static int |
toAllFlagValue(java.lang.Class<? extends java.lang.Enum<?>> enumClass)
Returns int-based "bit flags" representing the values of the given Enum class.
If the given Enum class is null , return 0. |
static <E extends java.lang.Enum<E>> |
toEnum(java.lang.Class<E> enumClass,
java.lang.String enumName)
Gets the enum for the class, returning
null if not found. |
static int |
toFlagValue(java.util.Collection<? extends java.lang.Enum<?>> enumList)
Returns int-based "bit flags" representing the values of the given list of enumerations.
If the given list of enumerations is null , return 0. |
static int |
toFlagValue(java.lang.Enum<?>... enumArray)
Returns int-based "bit flags" representing the values of the given enumerations.
If the given enumerations is null , return 0. |
static int |
toFlagValue(java.lang.Enum<?> e)
Returns int-based "bit flags" representing the value of the given enumeration.
If the given enumeration is null , return 0. |
static <T extends java.lang.Enum<T>> |
toStringArray(java.lang.Class<T> enumClass)
Converts an Enum to a String array.
|
public static int toFlagValue(java.lang.Enum<?> e)
null
, return 0.e
- Enumeration value to handle0
if e
is null
public static int toFlagValue(java.lang.Enum<?>... enumArray)
null
, return 0.enumArray
- Enumeration values to handle0
if enumArray
is null
public static int toFlagValue(java.util.Collection<? extends java.lang.Enum<?>> enumList)
null
, return 0.enumList
- Enumeration values to handle0
if enumList
is null
public static int toAllFlagValue(java.lang.Class<? extends java.lang.Enum<?>> enumClass)
null
, return 0.enumClass
- Enum class to handle0
if enumClass
is null
public static boolean isFlagSet(int value, java.lang.Enum<?> e)
value
- value to checke
- Enumeration valuetrue
the Enumeration value is flaggedpublic static <T extends java.lang.Enum<T>> java.lang.String[] toStringArray(java.lang.Class<T> enumClass)
enumClass
- Class
representing the EnumString
[]public static <E extends java.lang.Enum<E>> E toEnum(java.lang.Class<E> enumClass, java.lang.String enumName)
Gets the enum for the class, returning null
if not found.
This method differs from Enum.valueOf(java.lang.Class<T>, java.lang.String)
in that it does not throw an exception for an invalid enum name.
E
- the type of the enumerationenumClass
- the class of the enum to query, not nullenumName
- the enum name, null returns nullCopyright © 2001-2018 Jalios SA. All Rights Reserved.