Enum Class EnumGetMethod

java.lang.Object
java.lang.Enum<EnumGetMethod>
com.electronwill.nightconfig.core.EnumGetMethod
All Implemented Interfaces:
Serializable, Comparable<EnumGetMethod>, Constable

public enum EnumGetMethod extends Enum<EnumGetMethod>
Specifies how to treat non-enum values when using UnmodifiableConfig.getEnum(String, Class, EnumGetMethod).
  • Enum Constant Details

    • NAME

      public static final EnumGetMethod NAME
      If the config value is an enum constant, returns it as it is. If it's a String, returns the enum constant whose name exactly matches the string (string case-sensitive equality). If it's a value of another type, throws an error. In particular, throws an error if it's an Integer.
    • NAME_IGNORECASE

      public static final EnumGetMethod NAME_IGNORECASE
      If the config value is an enum constant, returns it as it is. If it's a String, returns the enum constant whose name matches the string, ignoring the case. If it's a value of another type, throws an error. In particular, throws an error if it's an Integer. This is the default method used by UnmodifiableConfig (and other classes) when not explicitely specified.
    • ORDINAL_OR_NAME

      public static final EnumGetMethod ORDINAL_OR_NAME
      If the config value is an enum constant, returns it as it is. If it's a String, returns the enum constant whose name exactly matches the string (string case-sensitive equality). If it's an Integer, returns the enum constant whose ordinal() is equal to the value. If it's a value of another type, throws an error.
    • ORDINAL_OR_NAME_IGNORECASE

      public static final EnumGetMethod ORDINAL_OR_NAME_IGNORECASE
      If the config value is an enum constant, returns it as it is. If it's a String, returns the enum constant whose name exactly matches the string. If it's an Integer, returns the enum constant whose ordinal() is equal to the value. If it's a value of another type, throws an error.
  • Method Details

    • values

      public static EnumGetMethod[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static EnumGetMethod valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isCaseSensitive

      public boolean isCaseSensitive()
    • isOrdinalOk

      public boolean isOrdinalOk()
    • get

      public <T extends Enum<T>> T get(Object value, Class<T> enumType)
    • validate

      public <T extends Enum<T>> boolean validate(Object value, Class<T> enumType)