Class EnumUtil

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

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

    Modifier and Type
    Method
    Description
    static boolean
    aLessEqualsThanB(org.apache.commons.lang.enums.ValuedEnum a, org.apache.commons.lang.enums.ValuedEnum b)
    checks whether the value of an enum is less or equal to another
    null is always smaller
    static boolean
    aLessThanB(org.apache.commons.lang.enums.ValuedEnum a, org.apache.commons.lang.enums.ValuedEnum b)
    checks whether the value of an enum is less than another
    null is always smaller
    static org.apache.commons.lang.enums.ValuedEnum
    getEnumIgnoreCase(Class<? extends org.apache.commons.lang.enums.ValuedEnum> clazz, Enum<?> e)
    get enum ignoring case
    static org.apache.commons.lang.enums.ValuedEnum
    getEnumIgnoreCase(Class<? extends org.apache.commons.lang.enums.ValuedEnum> clazz, String s)
     
    static String
    getEnumName(org.apache.commons.lang.enums.ValuedEnum en)
    null save convenience name getter
    static Vector<org.apache.commons.lang.enums.ValuedEnum>
    getEnumsVector(Class<? extends org.apache.commons.lang.enums.ValuedEnum> e)
    get a vector of elements in an iteration
    static <T extends Enum<T>>
    T
     
    static String
    getName(org.apache.commons.lang.enums.ValuedEnum en)
    null save convenience name getter
    getNamesList(Class<? extends org.apache.commons.lang.enums.ValuedEnum> e)
    get a vector of names in an iteration
    static VString
    getNamesVector(Class<? extends org.apache.commons.lang.enums.ValuedEnum> e)
    get a vector of names in an iteration
    static int
    getValue(org.apache.commons.lang.enums.ValuedEnum a)
     
    static org.apache.commons.lang.enums.ValuedEnum
    max(org.apache.commons.lang.enums.ValuedEnum e1, org.apache.commons.lang.enums.ValuedEnum e2)
    get the higher of two enum values, null is lowest
    static org.apache.commons.lang.enums.ValuedEnum
    min(org.apache.commons.lang.enums.ValuedEnum e1, org.apache.commons.lang.enums.ValuedEnum e2)
    get the lower of two enum values, null is lowest

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getNamesVector

      public static VString getNamesVector(Class<? extends org.apache.commons.lang.enums.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 org.apache.commons.lang.enums.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<org.apache.commons.lang.enums.ValuedEnum> getEnumsVector(Class<? extends org.apache.commons.lang.enums.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 org.apache.commons.lang.enums.ValuedEnum min(org.apache.commons.lang.enums.ValuedEnum e1, org.apache.commons.lang.enums.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 org.apache.commons.lang.enums.ValuedEnum max(org.apache.commons.lang.enums.ValuedEnum e1, org.apache.commons.lang.enums.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(org.apache.commons.lang.enums.ValuedEnum en)
      null save convenience name getter
      Parameters:
      en - the enum to get the name of the class
      Returns:
    • getEnumName

      public static String getEnumName(org.apache.commons.lang.enums.ValuedEnum en)
      null save convenience name getter
      Parameters:
      en - the enum to get the name
      Returns:
    • aLessThanB

      public static boolean aLessThanB(org.apache.commons.lang.enums.ValuedEnum a, org.apache.commons.lang.enums.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(org.apache.commons.lang.enums.ValuedEnum a)
    • aLessEqualsThanB

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

      public static org.apache.commons.lang.enums.ValuedEnum getEnumIgnoreCase(Class<? extends org.apache.commons.lang.enums.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: