Class JavaEnumUtil


  • public class JavaEnumUtil
    extends java.lang.Object
    class with utilities for enums
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends java.lang.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
      static <T extends java.lang.Enum<T>>
      boolean
      aLessThanB​(T a, T b)
      checks whether the value of an enum is less than another
      null is always smaller
      static <T extends java.lang.Enum<T>>
      T
      getEnumIgnoreCase​(java.lang.Class<T> c, java.lang.String val)  
      static <T extends java.lang.Enum<T>>
      T
      getEnumIgnoreCase​(java.lang.Class<T> c, java.lang.String val, T def)  
      static java.lang.String getName​(java.lang.Enum<?> en)
      null safe convenience name getter
      static <T extends java.lang.Enum<T>>
      java.util.List<java.lang.String>
      getNamesList​(java.lang.Class<T> c)  
      static <T extends java.lang.Enum<T>>
      T
      max​(T e1, T e2)
      get the higher of two enum values, null is lowest
      static <T extends java.lang.Enum<T>>
      T
      min​(T e1, T 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 Detail

      • min

        public static <T extends java.lang.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 java.lang.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 java.lang.String getName​(java.lang.Enum<?> en)
        null safe convenience name getter
        Parameters:
        en - the enum to get the name of the class
        Returns:
      • aLessThanB

        public static <T extends java.lang.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 java.lang.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 java.lang.Enum<T>> T getEnumIgnoreCase​(java.lang.Class<T> c,
                                                                        java.lang.String val)
        Type Parameters:
        T -
        Parameters:
        val -
        c -
        Returns:
      • getEnumIgnoreCase

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

        public static <T extends java.lang.Enum<T>> java.util.List<java.lang.String> getNamesList​(java.lang.Class<T> c)
        Type Parameters:
        T -
        Parameters:
        c -
        Returns: