public enum MapperFeature extends Enum<MapperFeature> implements ConfigFeature
ObjectMapper
, and accessible (but not changeable)
via ObjectReader
and ObjectWriter
(as well as
through various convenience methods through context objects).
Note that in addition to being only mutable via ObjectMapper
,
changes only take effect when done before any serialization or
deserialization calls -- that is, caller must follow
"configure-then-use" pattern.
Enum Constant and Description |
---|
ACCEPT_CASE_INSENSITIVE_ENUMS
Feature that determines if Enum deserialization should be case sensitive or not.
|
ACCEPT_CASE_INSENSITIVE_PROPERTIES
Feature that will allow for more forgiving deserialization of incoming JSON.
|
ALLOW_COERCION_OF_SCALARS
Feature that determines whether coercions from secondary representations are allowed
for simple non-textual scalar types: numbers and booleans.
|
ALLOW_EXPLICIT_PROPERTY_RENAMING
Feature that when enabled will allow explicitly named properties (i.e., fields or methods
annotated with
JsonProperty ("explicitName")) to
be re-named by a PropertyNamingStrategy , if one is configured. |
ALLOW_FINAL_FIELDS_AS_MUTATORS
Feature that determines whether member fields declared as 'final' may
be auto-detected to be used mutators (used to change value of the logical
property) or not.
|
AUTO_DETECT_CREATORS
Feature that determines whether "creator" methods are
automatically detected by consider public constructors,
and static single argument methods with name "valueOf".
|
AUTO_DETECT_FIELDS
Feature that determines whether non-static fields are recognized as
properties.
|
AUTO_DETECT_GETTERS
Feature that determines whether regular "getter" methods are
automatically detected based on standard Bean naming convention
or not.
|
AUTO_DETECT_IS_GETTERS
Feature that determines whether "is getter" methods are
automatically detected based on standard Bean naming convention
or not.
|
AUTO_DETECT_SETTERS
Feature that determines whether "setter" methods are
automatically detected based on standard Bean naming convention
or not.
|
CAN_OVERRIDE_ACCESS_MODIFIERS
Feature that determines whether method and field access
modifier settings can be overridden when accessing
properties.
|
DEFAULT_VIEW_INCLUSION
Feature that determines whether properties that have no view
annotations are included in JSON serialization views (see
JsonView for more
details on JSON Views). |
IGNORE_DUPLICATE_MODULE_REGISTRATIONS
Feature that determines whether multiple registrations of same module
should be ignored or not; if enabled, only the first registration call
results in module being called, and possible duplicate calls are silently
ignored; if disabled, no checking is done and all registration calls are
dispatched to module.
|
IGNORE_MERGE_FOR_UNMERGEABLE
Setting that determines what happens if an attempt is made to explicitly
"merge" value of a property, where value does not support merging; either
merging is skipped and new value is created (
true ) or
an exception is thrown (false). |
INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES
Feature that determines handling of
java.beans.ConstructorProperties |
INFER_PROPERTY_MUTATORS
Feature that determines whether member mutators (fields and
setters) may be "pulled in" even if they are not visible,
as long as there is a visible accessor (getter or field) with same name.
|
OVERRIDE_PUBLIC_ACCESS_MODIFIERS
Feature that determines that forces call to
AccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean) even for
public accessors -- that is, even if no such call is
needed from functionality perspective -- if call is allowed
(that is, CAN_OVERRIDE_ACCESS_MODIFIERS is set to true). |
PROPAGATE_TRANSIENT_MARKER
Feature that determines how
transient modifier for fields
is handled: if disabled, it is only taken to mean exclusion of the field
as accessor; if true, it is taken to imply removal of the whole property. |
REQUIRE_SETTERS_FOR_GETTERS
Feature that determines whether getters (getter methods)
can be auto-detected if there is no matching mutator (setter,
constructor parameter or field) or not: if set to true,
only getters that match a mutator are auto-discovered; if
false, all auto-detectable getters can be discovered.
|
SORT_PROPERTIES_ALPHABETICALLY
Feature that defines default property serialization order used
for POJO fields (note: does not apply to
Map
serialization!):
if enabled, default ordering is alphabetic (similar to
how JsonPropertyOrder.alphabetic()
works); if disabled, order is unspecified (based on what JDK gives
us, which may be declaration order, but is not guaranteed). |
USE_ANNOTATIONS
Feature that determines whether annotation introspection
is used for configuration; if enabled, configured
AnnotationIntrospector will be used: if disabled,
no annotations are considered. |
USE_BASE_TYPE_AS_DEFAULT_IMPL
Feature that specifies whether the declared base type of a polymorphic value
is to be used as the "default" implementation, if no explicit default class
is specified via
@JsonTypeInfo.defaultImpl annotation. |
USE_GETTERS_AS_SETTERS
Feature that determines whether otherwise regular "getter"
methods (but only ones that handle Collections and Maps,
not getters of other type)
can be used for purpose of getting a reference to a Collection
and Map to modify the property, without requiring a setter
method.
|
USE_STATIC_TYPING
Feature that determines whether the type detection for
serialization should be using actual dynamic runtime type,
or declared static type.
|
USE_STD_BEAN_NAMING
Feature that may be enabled to enforce strict compatibility with
Bean name introspection, instead of slightly different mechanism
Jackson defaults to.
|
USE_WRAPPER_NAME_AS_PROPERTY_NAME
Feature that can be enabled to make property names be
overridden by wrapper name (usually detected with annotations
as defined by
AnnotationIntrospector.findWrapperName(com.fasterxml.jackson.databind.introspect.Annotated) . |
Modifier and Type | Method and Description |
---|---|
boolean |
enabledByDefault()
Accessor for checking whether this feature is enabled by default.
|
boolean |
enabledIn(int flags)
Convenience method for checking whether feature is enabled in given bitmask
|
int |
getMask()
Returns bit mask for this feature instance
|
static MapperFeature |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static MapperFeature[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final MapperFeature USE_ANNOTATIONS
AnnotationIntrospector
will be used: if disabled,
no annotations are considered.
Feature is enabled by default.
public static final MapperFeature USE_GETTERS_AS_SETTERS
Note that such getters-as-setters methods have lower precedence than setters, so they are only used if no setter is found for the Map/Collection property.
Feature is enabled by default.
public static final MapperFeature PROPAGATE_TRANSIENT_MARKER
transient
modifier for fields
is handled: if disabled, it is only taken to mean exclusion of the field
as accessor; if true, it is taken to imply removal of the whole property.
Feature is disabled by default, meaning that existence of `transient` for a field does not necessarily lead to ignoral of getters or setters but just ignoring the use of field for access.
public static final MapperFeature AUTO_DETECT_CREATORS
Note that this feature has lower precedence than per-class annotations, and is only used if there isn't more granular configuration available.
Feature is enabled by default.
public static final MapperFeature AUTO_DETECT_FIELDS
Note that this feature has lower precedence than per-class annotations, and is only used if there isn't more granular configuration available.
Feature is enabled by default.
public static final MapperFeature AUTO_DETECT_GETTERS
Note that since version 1.3, this does NOT include
"is getters" (see AUTO_DETECT_IS_GETTERS
for details)
Note that this feature has lower precedence than per-class annotations, and is only used if there isn't more granular configuration available.
Feature is enabled by default.
public static final MapperFeature AUTO_DETECT_IS_GETTERS
Note that this feature has lower precedence than per-class annotations, and is only used if there isn't more granular configuration available.
Feature is enabled by default.
public static final MapperFeature AUTO_DETECT_SETTERS
Note that this feature has lower precedence than per-class annotations, and is only used if there isn't more granular configuration available.
Feature is enabled by default.
public static final MapperFeature REQUIRE_SETTERS_FOR_GETTERS
Feature is disabled by default.
public static final MapperFeature ALLOW_FINAL_FIELDS_AS_MUTATORS
Feature is enabled by default, for backwards compatibility reasons.
public static final MapperFeature INFER_PROPERTY_MUTATORS
Note that 'getters' are never inferred and need to be either visible (including bean-style naming) or explicitly annotated.
Feature is enabled by default.
public static final MapperFeature INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES
java.beans.ConstructorProperties
annotation: when enabled, it is considered as alias of
JsonCreator
, to mean that constructor
should be considered a property-based Creator; when disabled, only constructor
parameter name information is used, but constructor is NOT considered an explicit
Creator (although may be discovered as one using other annotations or heuristics).
Feature is mostly used to help interoperability with frameworks like Lombok
that may automatically generate ConstructorProperties
annotation
but without necessarily meaning that constructor should be used as Creator
for deserialization.
Feature is enabled by default.
public static final MapperFeature CAN_OVERRIDE_ACCESS_MODIFIERS
AccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean)
may be called to enable access to otherwise unaccessible objects.
Note that this setting may have significant performance implications, since access override helps remove costly access checks on each and every Reflection access. If you are considering disabling this feature, be sure to verify performance consequences if usage is performance sensitive. Also note that performance effects vary between Java platforms (JavaSE vs Android, for example), as well as JDK versions: older versions seemed to have more significant performance difference.
Conversely, on some platforms, it may be necessary to disable this feature as platform does not allow such calls. For example, when developing Applets (or other Java code that runs on tightly restricted sandbox), it may be necessary to disable the feature regardless of performance effects.
Feature is enabled by default.
public static final MapperFeature OVERRIDE_PUBLIC_ACCESS_MODIFIERS
AccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean)
even for
public
accessors -- that is, even if no such call is
needed from functionality perspective -- if call is allowed
(that is, CAN_OVERRIDE_ACCESS_MODIFIERS
is set to true).
The main reason to enable this feature is possible performance
improvement as JDK does not have to perform access checks; these
checks are otherwise made for all accessors, including public ones,
and may result in slower Reflection calls. Exact impact (if any)
depends on Java platform (Java SE, Android) as well as JDK version.
Feature is enabled by default, for legacy reasons (it was the behavior until 2.6)
public static final MapperFeature USE_STATIC_TYPING
This global default value can be overridden at class, method
or field level by using JsonSerialize.typing()
annotation
property.
Feature is disabled by default which means that dynamic runtime types are used (instead of declared static types) for serialization.
public static final MapperFeature USE_BASE_TYPE_AS_DEFAULT_IMPL
@JsonTypeInfo.defaultImpl
annotation.
Note that feature only has effect on deserialization of regular polymorphic properties: it does NOT affect non-polymorphic cases, and is unlikely to work with Default Typing.
Feature is disabled by default for backwards compatibility.
public static final MapperFeature DEFAULT_VIEW_INCLUSION
JsonView
for more
details on JSON Views).
If enabled, non-annotated properties will be included;
when disabled, they will be excluded. So this feature
changes between "opt-in" (feature disabled) and
"opt-out" (feature enabled) modes.
Default value is enabled, meaning that non-annotated
properties are included in all views if there is no
JsonView
annotation.
Feature is enabled by default.
public static final MapperFeature SORT_PROPERTIES_ALPHABETICALLY
Map
serialization!):
if enabled, default ordering is alphabetic (similar to
how JsonPropertyOrder.alphabetic()
works); if disabled, order is unspecified (based on what JDK gives
us, which may be declaration order, but is not guaranteed).
Note that this is just the default behavior, and can be overridden by
explicit overrides in classes (for example with
JsonPropertyOrder
annotation)
Feature is disabled by default.
public static final MapperFeature ACCEPT_CASE_INSENSITIVE_PROPERTIES
Note that there is additional performance overhead since incoming property names need to be lower-cased before comparison, for cases where there are upper-case letters. Overhead for names that are already lower-case should be negligible however.
Feature is disabled by default.
public static final MapperFeature ACCEPT_CASE_INSENSITIVE_ENUMS
Feature is disabled by default.
public static final MapperFeature USE_WRAPPER_NAME_AS_PROPERTY_NAME
AnnotationIntrospector.findWrapperName(com.fasterxml.jackson.databind.introspect.Annotated)
.
If enabled, all properties that have associated non-empty Wrapper
name will use that wrapper name instead of property name.
If disabled, wrapper name is only used for wrapping (if anything).
Feature is disabled by default.
public static final MapperFeature USE_STD_BEAN_NAMING
Feature is disabled by default for backwards compatibility purposes: earlier Jackson versions used Jackson's own mechanism.
public static final MapperFeature ALLOW_EXPLICIT_PROPERTY_RENAMING
JsonProperty
("explicitName")) to
be re-named by a PropertyNamingStrategy
, if one is configured.
Feature is disabled by default.
public static final MapperFeature ALLOW_COERCION_OF_SCALARS
When feature is disabled, only strictly compatible input may be bound: numbers for numbers, boolean values for booleans. When feature is enabled, conversions from JSON String are allowed, as long as textual value matches (for example, String "true" is allowed as equivalent of JSON boolean token `true`; or String "1.0" for `double`).
Note that it is possible that other configurability options can override this in closer scope (like on per-type or per-property basis); this is just the global default.
Feature is enabled by default (for backwards compatibility since this was the default behavior)
public static final MapperFeature IGNORE_DUPLICATE_MODULE_REGISTRATIONS
Definition of "same module" is based on using Module.getTypeId()
;
modules with same non-null type id
are considered same for
purposes of duplicate registration. This also avoids having to keep track
of actual module instances; only ids will be kept track of (and only if
this feature is enabled).
Feature is enabled by default.
public static final MapperFeature IGNORE_MERGE_FOR_UNMERGEABLE
true
) or
an exception is thrown (false).
Feature is disabled by default since non-mergeable property types are ignored even if defaults call for merging, and usually explicit per-type or per-property settings for such types should result in an exception.
public static MapperFeature[] values()
for (MapperFeature c : MapperFeature.values()) System.out.println(c);
public static MapperFeature valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic boolean enabledByDefault()
ConfigFeature
enabledByDefault
in interface ConfigFeature
public int getMask()
ConfigFeature
getMask
in interface ConfigFeature
public boolean enabledIn(int flags)
ConfigFeature
enabledIn
in interface ConfigFeature
Copyright © 2008–2020 FasterXML. All rights reserved.