Class EnumUtil

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

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

    • getNamesVector

      public static VString getNamesVector(Class<? extends ValuedEnum> e)
      get a vector of names in an iteration
      Parameters:
      e - any member of the enum to iterate over
      Returns:
      VString - the vector of enum names
    • getNamesList

      public static StringArray getNamesList(Class<? extends ValuedEnum> e)
      get a vector of names in an iteration
      Parameters:
      e - any member of the enum to iterate over
      Returns:
      VString - the vector of enum names
    • getEnumsVector

      public static Vector<ValuedEnum> getEnumsVector(Class<? extends ValuedEnum> e)
      get a vector of elements in an iteration
      Parameters:
      e - any member of the enum to iterate over
      Returns:
      Vector - the vector of enum instances
    • min

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

      public static ValuedEnum max(ValuedEnum e1, ValuedEnum 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(ValuedEnum en)
      null save convenience name getter
      Parameters:
      en - the enum to get the name of the class
      Returns:
    • getEnumName

      public static String getEnumName(ValuedEnum en)
      null save convenience name getter
      Parameters:
      en - the enum to get the name
      Returns:
    • aLessThanB

      public static boolean aLessThanB(ValuedEnum a, ValuedEnum 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
    • getValue

      public static int getValue(ValuedEnum a)
    • aLessEqualsThanB

      public static boolean aLessEqualsThanB(ValuedEnum a, ValuedEnum 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 ValuedEnum getEnumIgnoreCase(Class<? extends ValuedEnum> clazz, Enum<?> e)
      get enum ignoring case
      Parameters:
      clazz - the jdflib valued enum class
      e - the enum
      Returns:
    • getEnum

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

      public static ValuedEnum getEnumIgnoreCase(Class<? extends ValuedEnum> clazz, String s)
      Parameters:
      clazz -
      s -
      Returns:
    • getJavaEnumIgnoreCase

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

      public static <T extends Enum<T>> T getJavaEnum(ValuedEnum val)
      Type Parameters:
      T -
      T -
      Parameters:
      val -
      c -
      Returns:
    • getJavaEnumClass

      public static <J extends Enum<J>> Class<J> getJavaEnumClass(ValuedEnum val)
      Type Parameters:
      J -
      J -
      Parameters:
      val -
      c -
      Returns:
    • getOldEnum

      public static <T extends ValuedEnum, E extends Enum<E>> T getOldEnum(E val)
      Type Parameters:
      T -
      T -
      Parameters:
      val -
      c -
      Returns:
    • getOldEnumClass

      public static <O extends ValuedEnum, E extends Enum<E>> Class<O> getOldEnumClass(Enum<E> oldEnum)
      Type Parameters:
      O -
      O -
      E -
      Parameters:
      oldEnum -
      c -
      Returns: