com.fasterxml.jackson.databind
Enum MapperFeature

java.lang.Object
  extended by java.lang.Enum<MapperFeature>
      extended by com.fasterxml.jackson.databind.MapperFeature
All Implemented Interfaces:
ConfigFeature, Serializable, Comparable<MapperFeature>

public enum MapperFeature
extends Enum<MapperFeature>
implements ConfigFeature

Enumeration that defines simple on/off features to set for 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 Summary
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 regualr "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).
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_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_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).
 
Method Summary
 boolean enabledByDefault()
          Accessor for checking whether this feature is enabled by default.
 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.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

USE_ANNOTATIONS

public static final MapperFeature 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.

Feature is enabled by default.


AUTO_DETECT_CREATORS

public static final MapperFeature AUTO_DETECT_CREATORS
Feature that determines whether "creator" methods are automatically detected by consider public constructors, and static single argument methods with name "valueOf". If disabled, only methods explicitly annotated are considered creator methods (except for the no-arg default constructor which is always considered a factory method).

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.


AUTO_DETECT_FIELDS

public static final MapperFeature AUTO_DETECT_FIELDS
Feature that determines whether non-static fields are recognized as properties. If yes, then all public member fields are considered as properties. If disabled, only fields explicitly annotated are considered property 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.


AUTO_DETECT_GETTERS

public static final MapperFeature AUTO_DETECT_GETTERS
Feature that determines whether regualr "getter" methods are automatically detected based on standard Bean naming convention or not. If yes, then all public zero-argument methods that start with prefix "get" are considered as getters. If disabled, only methods explicitly annotated are considered 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.


AUTO_DETECT_IS_GETTERS

public static final MapperFeature AUTO_DETECT_IS_GETTERS
Feature that determines whether "is getter" methods are automatically detected based on standard Bean naming convention or not. If yes, then all public zero-argument methods that start with prefix "is", and whose return type is boolean are considered as "is getters". If disabled, only methods explicitly annotated are considered 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.


AUTO_DETECT_SETTERS

public static final MapperFeature AUTO_DETECT_SETTERS
Feature that determines whether "setter" methods are automatically detected based on standard Bean naming convention or not. If yes, then all public one-argument methods that start with prefix "set" are considered setters. If disabled, only methods explicitly annotated are considered 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.


REQUIRE_SETTERS_FOR_GETTERS

public static final MapperFeature 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.

Feature is disabled by default.


USE_GETTERS_AS_SETTERS

public static final MapperFeature 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. This is similar to how JAXB framework sets Collections and Maps: no setter is involved, just setter.

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.


CAN_OVERRIDE_ACCESS_MODIFIERS

public static final MapperFeature CAN_OVERRIDE_ACCESS_MODIFIERS
Feature that determines whether method and field access modifier settings can be overridden when accessing properties. If enabled, method AccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean) may be called to enable access to otherwise unaccessible objects.

Feature is enabled by default.


USE_STATIC_TYPING

public static final MapperFeature USE_STATIC_TYPING
Feature that determines whether the type detection for serialization should be using actual dynamic runtime type, or declared static type. Note that deserialization always uses declared static types since no runtime types are available (as we are creating instances after using type information).

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.


DEFAULT_VIEW_INCLUSION

public static final MapperFeature 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). 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.


SORT_PROPERTIES_ALPHABETICALLY

public static final MapperFeature 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).

Note that this is just the default behavior, and can be overridden by explicit overrides in classes.

Feature is disabled by default.


USE_WRAPPER_NAME_AS_PROPERTY_NAME

public static final MapperFeature 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). 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.

Since:
2.1
Method Detail

values

public static MapperFeature[] 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 (MapperFeature c : MapperFeature.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static MapperFeature valueOf(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:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

enabledByDefault

public boolean enabledByDefault()
Description copied from interface: ConfigFeature
Accessor for checking whether this feature is enabled by default.

Specified by:
enabledByDefault in interface ConfigFeature

getMask

public int getMask()
Description copied from interface: ConfigFeature
Returns bit mask for this feature instance

Specified by:
getMask in interface ConfigFeature


Copyright © 2012 FasterXML. All Rights Reserved.