Package de.eldoria.eldoutilities.utils
Class EnumUtil
java.lang.Object
de.eldoria.eldoutilities.utils.EnumUtil
This class contains methods to parse string to enums.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionenumValues
(Class<T> clazz) enumValues
(Class<T> clazz, String delimiter) Searches for a enum value by string with a case insensitive search.Searches for a enum value by string with a case insensitive search.static <T extends Enum<T>>
TSearches for a enum value by string with a case insensitive search.static <T extends Enum<T>>
TSearches for a enum value by string with a case insensitive search.
-
Method Details
-
parse
Searches for a enum value by string with a case insensitive search.- Type Parameters:
T
- type of enum.- Parameters:
value
- enum as string valuevalues
- enum values.- Returns:
- enum value or null if no mathing value was found.
-
parse
public static <T extends Enum<T>> T parse(String value, Class<T> values, boolean stripStrings, T defaultValue) Searches for a enum value by string with a case insensitive search.- Type Parameters:
T
- type of enum.- Parameters:
value
- enum as string valuevalues
- enum values.stripStrings
- if true underscores will be removed before checkingdefaultValue
- Default value which will be returned when enum could not be parsed- Returns:
- enum value or default when value was null
-
parse
Searches for a enum value by string with a case insensitive search.- Type Parameters:
T
- type of enum.- Parameters:
value
- enum as string valuevalues
- enum values.defaultValue
- Default value which will be returned when enum could not be parsed- Returns:
- enum value or default when value was null
-
parse
public static <T extends Enum<T>> Optional<T> parse(String mat, Class<T> values, boolean stripStrings) Searches for a enum value by string with a case insensitive search.- Type Parameters:
T
- type of enum.- Parameters:
mat
- enum as string valuevalues
- enum values.stripStrings
- if true underscores will be removed before checking- Returns:
- enum value or null if no mathing value was found.
-
enumValues
-
enumValues
-