Class EnumUtil

java.lang.Object
de.eldoria.eldoutilities.utils.EnumUtil

public final class EnumUtil extends Object
This class contains methods to parse string to enums.
Since:
1.0.0
  • Method Details

    • parse

      public static <T extends Enum<T>> Optional<T> parse(String value, Class<T> values)
      Searches for a enum value by string with a case insensitive search.
      Type Parameters:
      T - type of enum.
      Parameters:
      value - enum as string value
      values - 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 value
      values - enum values.
      stripStrings - if true underscores will be removed before checking
      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>> T parse(String value, Class<T> values, 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 value
      values - 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 value
      values - enum values.
      stripStrings - if true underscores will be removed before checking
      Returns:
      enum value or null if no mathing value was found.
    • enumValues

      public static <T extends Enum<T>> String enumValues(Class<T> clazz)
    • enumValues

      public static <T extends Enum<T>> String enumValues(Class<T> clazz, String delimiter)