Enum EnumGetMethod
- java.lang.Object
-
- java.lang.Enum<EnumGetMethod>
-
- com.electronwill.nightconfig.core.EnumGetMethod
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<EnumGetMethod>
public enum EnumGetMethod extends java.lang.Enum<EnumGetMethod>
Specifies how to treat non-enum values when usingUnmodifiableConfig.getEnum(String, Class, EnumGetMethod).
-
-
Enum Constant Summary
Enum Constants Enum Constant Description NAMEIf the config value is an enum constant, returns it as it is.NAME_IGNORECASEIf the config value is an enum constant, returns it as it is.ORDINAL_OR_NAMEIf the config value is an enum constant, returns it as it is.ORDINAL_OR_NAME_IGNORECASEIf the config value is an enum constant, returns it as it is.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends java.lang.Enum<T>>
Tget(java.lang.Object value, java.lang.Class<T> enumType)booleanisCaseSensitive()booleanisOrdinalOk()<T extends java.lang.Enum<T>>
booleanvalidate(java.lang.Object value, java.lang.Class<T> enumType)static EnumGetMethodvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static EnumGetMethod[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
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 byUnmodifiableConfig(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 whoseordinal()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 whoseordinal()is equal to the value. If it's a value of another type, throws an error.
-
-
Method Detail
-
values
public static EnumGetMethod[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (EnumGetMethod c : EnumGetMethod.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static EnumGetMethod valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
isCaseSensitive
public boolean isCaseSensitive()
-
isOrdinalOk
public boolean isOrdinalOk()
-
get
public <T extends java.lang.Enum<T>> T get(java.lang.Object value, java.lang.Class<T> enumType)
-
validate
public <T extends java.lang.Enum<T>> boolean validate(java.lang.Object value, java.lang.Class<T> enumType)
-
-