Class JavaEnumUtil

java.lang.Object
org.cip4.jdflib.util.JavaEnumUtil

public class JavaEnumUtil extends Object
class with utilities for enums
  • Method Details

    • min

      public static <T extends Enum<T>> T min(T e1, T e2)
      get the lower of two enum values, null is lowest
      Parameters:
      e1 -
      e2 -
      Returns:
      the lower of the two values
    • max

      public static <T extends Enum<T>> T max(T e1, T e2)
      get the higher of two enum values, null is lowest
      Parameters:
      e1 -
      e2 -
      Returns:
      the higher of the two values
    • getName

      public static String getName(Enum<?> en)
      null safe convenience name getter
      Parameters:
      en - the enum to get the name of the class
      Returns:
    • aLessThanB

      public static <T extends Enum<T>> boolean aLessThanB(T a, T b)
      checks whether the value of an enum is less than another
      null is always smaller
      Parameters:
      a - the first enum; if this is smaller we return true
      b - the second enum
      Returns:
      boolean a is < b
    • aLessEqualsThanB

      public static <T extends Enum<T>> boolean aLessEqualsThanB(T a, T b)
      checks whether the value of an enum is less or equal to another
      null is always smaller
      Parameters:
      a - the first enum; if this is smaller we return true
      b - the second enum
      Returns:
      boolean a is <= b
    • getEnumIgnoreCase

      public static <T extends Enum<T>> T getEnumIgnoreCase(Class<T> c, String val)
      Type Parameters:
      T -
      Parameters:
      val -
      c -
      Returns:
    • getEnumIgnoreCase

      public static <T extends Enum<T>> T getEnumIgnoreCase(Class<T> c, String val, T def)
      Type Parameters:
      T -
      Parameters:
      c -
      val -
      def - the default
      Returns:
    • getNamesList

      public static <T extends Enum<T>> List<String> getNamesList(Class<T> c)
      Type Parameters:
      T -
      Parameters:
      c -
      Returns:
    • getNameList

      public static <T extends Enum<T>> StringArray getNameList(Collection<T> esn, boolean unique)
      null safe convenience name list getter
      Parameters:
      esn - the enum collection to get the list of names
      Returns:
    • getEnumList

      public static <T extends Enum<T>> List<T> getEnumList(Class<T> c, Collection<String> strings, boolean unique)
      null safe convenience name list getter
      Parameters:
      esn - the enum collection to get the list of names
      Returns:
    • getEnumList

      public static <T extends Enum<T>> List<T> getEnumList(Class<T> c, String strings, boolean unique)
      null safe convenience name list getter
      Parameters:
      esn - the enum collection to get the list of names
      Returns: