Top Description Fields Constructors Methods
tools.jackson.databind.cfg

public final Enum EnumFeature

extends Enum<EnumFeature>
implements DatatypeFeature
Class Inheritance
All Implemented Interfaces
tools.jackson.databind.cfg.DatatypeFeature, tools.jackson.core.util.JacksonFeature
Imports
tools.jackson.databind.DatabindException

New Datatype-specific configuration options related to handling of java.lang.Enum types.

Field Summary

Modifier and TypeField and Description
private final boolean
_enabledByDefault

Whether feature is enabled or disabled by default.

private final int
public static final EnumFeature
FAIL_ON_NUMBERS_FOR_ENUMS

Feature that determines whether JSON integer numbers are valid values to be used for deserializing Java enum values.

private static final int
public static final EnumFeature
READ_ENUM_KEYS_USING_INDEX

Feature that determines standard deserialization mechanism used for Enum values: if enabled, Enums are assumed to have been serialized using index of Enum;

Note

this feature should be symmetric to as WRITE_ENUM_KEYS_USING_INDEX.

public static final EnumFeature
READ_ENUMS_USING_TO_STRING

Feature that determines the deserialization mechanism used for Enum values: if enabled, Enums are assumed to have been serialized using return value of Enum.toString(); if disabled, return value of Enum.name() is assumed to have been used.

public static final EnumFeature
READ_UNKNOWN_ENUM_VALUES_AS_NULL

Feature that allows unknown Enum values to be parsed as null values.

public static final EnumFeature
READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE

Feature that allows unknown Enum values to be ignored and replaced by a predefined value specified through @JsonEnumDefaultValue annotation.

public static final EnumFeature
WRITE_ENUM_KEYS_USING_INDEX

Feature that determines whether {link Enum}s used as java.util.Map keys are serialized as using Enum#ordinal() or not.

public static final EnumFeature
WRITE_ENUMS_TO_LOWERCASE

Feature that determines standard serialization mechanism used for Enum values: if enabled, return value of Enum.name().toLowerCase() is used; if disabled, return value of Enum.name() is used.

public static final EnumFeature
WRITE_ENUMS_USING_INDEX

Feature that determines whether Java Enum values are serialized as numbers (true), or textual values (false).

public static final EnumFeature
WRITE_ENUMS_USING_TO_STRING

Feature that determines standard serialization mechanism used for Enum values: if enabled, return value of Enum.toString() is used; if disabled, return value of Enum.name() is used.

Constructor Summary

AccessConstructor and Description
private
EnumFeature(boolean enabledByDefault)

Method Summary

Modifier and TypeMethod and Description
public boolean
enabledByDefault()

Implements tools.jackson.core.util.JacksonFeature.enabledByDefault.

Accessor for checking whether this feature is enabled by default.

public boolean
enabledIn(int flags)

Implements tools.jackson.core.util.JacksonFeature.enabledIn.

Convenience method for checking whether feature is enabled in given bitmask.

public int
featureIndex()

Implements tools.jackson.databind.cfg.DatatypeFeature.featureIndex.

Internal index used for efficient storage and index; no user serviceable contents inside!

public int
getMask()

Implements tools.jackson.core.util.JacksonFeature.getMask.

Returns bit mask for this feature instance; must be a single bit, that is of form 1 << N.

public static EnumFeature
public static EnumFeature[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

_enabledByDefaultback to summary
private final boolean _enabledByDefault

Whether feature is enabled or disabled by default.

_maskback to summary
private final int _mask
FAIL_ON_NUMBERS_FOR_ENUMSback to summary
public static final EnumFeature FAIL_ON_NUMBERS_FOR_ENUMS

Feature that determines whether JSON integer numbers are valid values to be used for deserializing Java enum values. If set to 'false' numbers are acceptable and are used to map to ordinal() of matching enumeration value; if 'true', numbers are not allowed and a DatabindException will be thrown. Latter behavior makes sense if there is concern that accidental mapping from integer values to enums might happen (and when enums are always serialized as JSON Strings)

Feature used to be one of tools.jackson.databind.DeserializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is disabled by default.

FEATURE_INDEXback to summary
private static final int FEATURE_INDEX
READ_ENUM_KEYS_USING_INDEXback to summary
public static final EnumFeature READ_ENUM_KEYS_USING_INDEX

Feature that determines standard deserialization mechanism used for Enum values: if enabled, Enums are assumed to have been serialized using index of Enum;

Note

this feature should be symmetric to as WRITE_ENUM_KEYS_USING_INDEX.

Feature is disabled by default.

Since
2.15
READ_ENUMS_USING_TO_STRINGback to summary
public static final EnumFeature READ_ENUMS_USING_TO_STRING

Feature that determines the deserialization mechanism used for Enum values: if enabled, Enums are assumed to have been serialized using return value of Enum.toString(); if disabled, return value of Enum.name() is assumed to have been used.

Note

this feature should usually have same value as WRITE_ENUMS_USING_TO_STRING.

Feature used to be one of tools.jackson.databind.DeserializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is enabled by default as of Jackson 3.0 (in 2.x it was disabled).

READ_UNKNOWN_ENUM_VALUES_AS_NULLback to summary
public static final EnumFeature READ_UNKNOWN_ENUM_VALUES_AS_NULL

Feature that allows unknown Enum values to be parsed as null values. If disabled, unknown Enum values will throw exceptions.

Note that in some cases this will effectively ignore unknown Enum values, e.g. when the unknown values are used as keys of java.util.EnumMap or values of java.util.EnumSet: this is because these data structures cannot store null values.

Also note that this feature has lower precedence than READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, meaning this feature will work only if latter feature is disabled.

Feature used to be one of tools.jackson.databind.DeserializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is disabled by default.

READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUEback to summary
public static final EnumFeature READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE

Feature that allows unknown Enum values to be ignored and replaced by a predefined value specified through @JsonEnumDefaultValue annotation. If disabled, unknown Enum values will throw exceptions. If enabled, but no predefined default Enum value is specified, an exception will be thrown as well.

Note that this feature has higher precedence than READ_UNKNOWN_ENUM_VALUES_AS_NULL.

Feature used to be one of tools.jackson.databind.DeserializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is disabled by default.

WRITE_ENUM_KEYS_USING_INDEXback to summary
public static final EnumFeature WRITE_ENUM_KEYS_USING_INDEX

Feature that determines whether {link Enum}s used as java.util.Map keys are serialized as using Enum#ordinal() or not. Similar to WRITE_ENUMS_USING_INDEX used when writing Enums as regular values.

Note

counterpart for this settings is EnumFeature#READ_ENUM_KEYS_USING_INDEX.

Feature used to be one of tools.jackson.databind.SerializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is disabled by default.

WRITE_ENUMS_TO_LOWERCASEback to summary
public static final EnumFeature WRITE_ENUMS_TO_LOWERCASE

Feature that determines standard serialization mechanism used for Enum values: if enabled, return value of Enum.name().toLowerCase() is used; if disabled, return value of Enum.name() is used.

Note

this feature CANNOT be changed on per-call basis: it will have to be set on ObjectMapper before use

Feature is disabled by default.

Since
2.15
WRITE_ENUMS_USING_INDEXback to summary
public static final EnumFeature WRITE_ENUMS_USING_INDEX

Feature that determines whether Java Enum values are serialized as numbers (true), or textual values (false). If textual values are used, other settings are also considered. If this feature is enabled, return value of Enum.ordinal() (an integer) will be used as the serialization.

Note that this feature has precedence over WRITE_ENUMS_USING_TO_STRING, which is only considered if this feature is set to false.

Note that since 2.10, this does NOT apply to Enums written as keys of java.util.Map values, which has separate setting, WRITE_ENUM_KEYS_USING_INDEX.

Feature used to be one of tools.jackson.databind.SerializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is disabled by default.

WRITE_ENUMS_USING_TO_STRINGback to summary
public static final EnumFeature WRITE_ENUMS_USING_TO_STRING

Feature that determines standard serialization mechanism used for Enum values: if enabled, return value of Enum.toString() is used; if disabled, return value of Enum.name() is used.

Note

this feature should usually have same value as READ_ENUMS_USING_TO_STRING.

Feature used to be one of tools.jackson.databind.SerializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is enabled by default as of Jackson 3.0 (in 2.x it was disabled).

Constructor Detail

EnumFeatureback to summary
private EnumFeature(boolean enabledByDefault)

Method Detail

enabledByDefaultback to summary
public boolean enabledByDefault()

Implements tools.jackson.core.util.JacksonFeature.enabledByDefault.

Doc from tools.jackson.core.util.JacksonFeature.enabledByDefault.

Accessor for checking whether this feature is enabled by default.

Annotations
@Override
enabledInback to summary
public boolean enabledIn(int flags)

Implements tools.jackson.core.util.JacksonFeature.enabledIn.

Doc from tools.jackson.core.util.JacksonFeature.enabledIn.

Convenience method for checking whether feature is enabled in given bitmask.

Annotations
@Override
featureIndexback to summary
public int featureIndex()

Implements tools.jackson.databind.cfg.DatatypeFeature.featureIndex.

Doc from tools.jackson.databind.cfg.DatatypeFeature.featureIndex.

Internal index used for efficient storage and index; no user serviceable contents inside!

Annotations
@Override
getMaskback to summary
public int getMask()

Implements tools.jackson.core.util.JacksonFeature.getMask.

Doc from tools.jackson.core.util.JacksonFeature.getMask.

Returns bit mask for this feature instance; must be a single bit, that is of form 1 << N.

Annotations
@Override
valueOfback to summary
public static EnumFeature valueOf(String name)
valuesback to summary
public static EnumFeature[] values()