Package io.dropwizard.util
Class Enums
- java.lang.Object
-
- io.dropwizard.util.Enums
-
public class Enums extends Object
Helper methods for enum types.
-
-
Constructor Summary
Constructors Constructor Description Enums()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @Nullable Enum<?>
fromStringFuzzy(String value, Enum<?>[] constants)
Convert a string to an enum with more permissive rules thanEnum
valueOf().
-
-
-
Method Detail
-
fromStringFuzzy
public static @Nullable Enum<?> fromStringFuzzy(String value, Enum<?>[] constants)
Convert a string to an enum with more permissive rules thanEnum
valueOf().
This method is more permissive in the following ways:- Whitespace is permitted but stripped from the input.
- Dashes and periods in the value are converted to underscores.
- Matching against the enum values is case insensitive.
- Parameters:
value
- The string to convert.constants
- The list of constants for theEnum
to which you wish to convert.- Returns:
- The enum or null, if no enum constant matched the input value.
-
-