Class EnumConstant

java.lang.Object
com.saperion.util.EnumConstant

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

    • get

      public static <T extends Enum<?>> T get(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