Package com.jalios.util
Class EnumUtils
java.lang.Object
com.jalios.util.EnumUtils
Utils Class to handle enumeration values to int-based "bit flags".
- Author:
- Nicolas Dos Santos
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks whether the int-based "bit flags" representation of the given enumeration value is present in the given value.static inttoAllFlagValue(Class<? extends Enum<?>> enumClass) Returns int-based "bit flags" representing the values of the given Enum class.
If the given Enum class isnull, return 0.static <E extends Enum<E>>
EGets the enum for the class, returningnullif not found.static inttoFlagValue(Enum<?> e) Returns int-based "bit flags" representing the value of the given enumeration.
If the given enumeration isnull, return 0.static inttoFlagValue(Enum<?>... enumArray) Returns int-based "bit flags" representing the values of the given enumerations.
If the given enumerations isnull, return 0.static inttoFlagValue(Collection<? extends Enum<?>> enumList) Returns int-based "bit flags" representing the values of the given list of enumerations.
If the given list of enumerations isnull, return 0.toStringArray(Class<T> enumClass) Converts an Enum to a String array.
-
Method Details
-
toFlagValue
Returns int-based "bit flags" representing the value of the given enumeration.
If the given enumeration isnull, return 0.- Parameters:
e- Enumeration value to handle- Returns:
- int-based "bit flags", or
0ifeisnull
-
toFlagValue
Returns int-based "bit flags" representing the values of the given enumerations.
If the given enumerations isnull, return 0.- Parameters:
enumArray- Enumeration values to handle- Returns:
- int-based "bit flags", or
0ifenumArrayisnull
-
toFlagValue
Returns int-based "bit flags" representing the values of the given list of enumerations.
If the given list of enumerations isnull, return 0.- Parameters:
enumList- Enumeration values to handle- Returns:
- int-based "bit flags", or
0ifenumListisnull
-
toAllFlagValue
Returns int-based "bit flags" representing the values of the given Enum class.
If the given Enum class isnull, return 0.- Parameters:
enumClass- Enum class to handle- Returns:
- int-based "bit flags", or
0ifenumClassisnull
-
isFlagSet
Checks whether the int-based "bit flags" representation of the given enumeration value is present in the given value.- Parameters:
value- value to checke- Enumeration value- Returns:
truethe Enumeration value is flagged
-
toStringArray
Converts an Enum to a String array. -
toEnum
Gets the enum for the class, returning
nullif 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.- Type Parameters:
E- the type of the enumeration- Parameters:
enumClass- the class of the enum to query, not nullenumName- the enum name, null returns null- Returns:
- the enum, null if not found
-