Class EnumConstant


  • public final class EnumConstant
    extends java.lang.Object
    Utility class that can be used to safely retrieve enum constants by their position in the value-array.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends java.lang.Enum<?>>
      T
      get​(java.lang.Class<T> clazz, int position, T defaultValue)
      Retrieves the enum-constant at the specified position in the value-array of the Enum defined by the specified class.
      • Methods inherited from class java.lang.Object

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

      • get

        public static <T extends java.lang.Enum<?>> T get​(java.lang.Class<T> clazz,
                                                          int position,
                                                          T defaultValue)
        Retrieves the enum-constant at the specified position in the value-array of the Enum defined by the specified class. If the class is not an Enum, or if there is no constant at the specified position in the array, the default value will be returned.
        Type Parameters:
        T - the type of the Enum
        Parameters:
        clazz - Class defining the Enum to read from
        position - the position of the constant in the value-array
        defaultValue - the default value to return if no constant was found
        Returns:
        enum constant or default value, if no constant was found