Class EnumUtils

java.lang.Object
org.kohsuke.github.internal.EnumUtils

public final class EnumUtils extends Object
Utils for Enums.
  • Method Details

    • getNullableEnumOrDefault

      public static <E extends Enum<E>> E getNullableEnumOrDefault(Class<E> enumClass, String value, E defaultEnum)
      Returns an enum value matching the value if found, null if the value is null and defaultEnum if the value cannot be matched to a value of the enum.

      The value is converted to uppercase before being matched to the enum values.

      Type Parameters:
      E - the type of the enum
      Parameters:
      enumClass - the type of the enum
      value - the value to interpret
      defaultEnum - the default enum value if the value doesn't match one of the enum value
      Returns:
      an enum value or null
    • getEnumOrDefault

      public static <E extends Enum<E>> E getEnumOrDefault(Class<E> enumClass, String value, E defaultEnum)
      Returns an enum value matching the value if found, defaultEnum if the value is null or cannot be matched to a value of the enum.
      Type Parameters:
      E - the type of the enum
      Parameters:
      enumClass - the type of the enum
      value - the value to interpret
      defaultEnum - the default enum value if the value doesn't match one of the enum value
      Returns:
      an enum value