Class EnumSupport

java.lang.Object
org.opencastproject.util.EnumSupport

public final class EnumSupport extends Object
Enum utility methods.
  • Method Details

    • fromString

      public static <E extends Enum<?>> E fromString(Class<E> enumClass, String value)
      Support method to help enums implement an enhanced valueOf(String) method, that does not throw an IllegalArgumentException in case of incoming values, that do not match any of the enum's values.
      Parameters:
      enumClass - the enum's class
      value - the value to look up
      Returns:
      the matching enum value or null if none matches
    • parseEnum

      public static <A extends Enum<A>> Function<String,Optional<A>> parseEnum(A e)
      Create a function to parse a string into an Enum value.