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

public abstract Class MapperBuilder<M extends ObjectMapper, B extends MapperBuilder<M, B>>

extends Object
Class Inheritance
Known Direct Subclasses
tools.jackson.databind.json.JsonMapper.Builder, tools.jackson.databind.ObjectMapper.PrivateBuilder
Imports
java.security.AccessController, .PrivilegedAction, java.text.DateFormat, java.util.*, java.util.function.Consumer, .UnaryOperator, com.fasterxml.jackson.annotation.JsonInclude, .JsonSetter, .JsonTypeInfo, tools.jackson.core.*, tools.jackson.core.util.DefaultPrettyPrinter, .Snapshottable, tools.jackson.databind.*, tools.jackson.databind.deser.*, tools.jackson.databind.ext.javatime.JavaTimeInitializer, tools.jackson.databind.introspect.*, tools.jackson.databind.jsontype.*, tools.jackson.databind.jsontype.impl.DefaultTypeResolverBuilder, .StdSubtypeResolver, tools.jackson.databind.node.JsonNodeFactory, tools.jackson.databind.ser.*, tools.jackson.databind.type.LogicalType, .TypeFactory, .TypeModifier, tools.jackson.databind.util.ArrayBuilders, .LinkedNode, .RootNameLookup, .StdDateFormat

Since ObjectMapper instances are immutable in Jackson 3.x for full thread-safety, we need means to construct configured instances. This is the shared base API for builders for all types of mappers.
Since
3.0

Field Summary

Modifier and TypeField and Description
protected AbstractTypeResolver[]
protected BaseSettings
protected ClassIntrospector
_classIntrospector

Introspector used to figure out Bean properties needed for bean serialization and deserialization.

protected final CoercionConfigs
_coercionConfigs

Coercion settings (global, per-type overrides)

protected final ConfigOverrides
_configOverrides

Various configuration setting overrides, both global base settings and per-class overrides.

protected DatatypeFeatures
protected ContextAttributes
_defaultAttributes

Explicitly configured default ContextAttributes, if any.

protected PrettyPrinter
protected int
protected DeserializationContexts
_deserializationContexts

Factory to use for creating per-operation contexts.

protected DeserializerFactory
protected FilterProvider
protected int
_formatReadFeatures

Optional per-format parser feature flags.

protected int
_formatWriteFeatures

Optional per-format generator feature flags.

protected InjectableValues
_injectableValues

Provider for values to inject in deserialized POJOs.

protected long
_mapperFeatures

Set of shared mapper features enabled.

protected MixInHandler
_mixInHandler

Handler responsible for resolving mix-in classes registered, if any.

protected Map<Object, JacksonModule>
_modules

Modules registered for addition, indexed by registration id.

protected LinkedNode<DeserializationProblemHandler>
_problemHandlers

Optional handlers that application may register to try to work-around various problem situations during deserialization

protected transient MapperBuilderState
_savedState

Configuration state after direct access, immediately before registration of modules (if any) and construction of actual mapper.

protected int
protected SerializationContexts
protected SerializerFactory
protected TokenStreamFactory
_streamFactory

Underlying stream factory

protected int
_streamReadFeatures

States of StreamReadFeatures to enable/disable.

protected int
_streamWriteFeatures

States of StreamWriteFeatures to enable/disable.

protected SubtypeResolver
protected TypeFactory
_typeFactory

Specific factory used for creating JavaType instances; needed to allow modules to add more custom type handling (mostly to support types of non-Java JVM languages)

protected TypeResolverProvider
protected static final AccessorNamingStrategy.Provider
protected static final AnnotationIntrospector
protected static final BaseSettings
protected static final int
protected static final long
protected static final PrettyPrinter
protected static final int
protected static final TypeResolverProvider
protected static final PolymorphicTypeValidator
protected static final AbstractTypeResolver[]

Constructor Summary

AccessConstructor and Description
protected
protected
MapperBuilder(MapperBuilderState state)

Constructor used to support "rebuild", starting with a previously taken snapshot, in order to create mappers that start with a known state of configuration, including a set of modules to register.

Method Summary

Modifier and TypeMethod and Description
protected ModuleContextBase
protected ClassIntrospector
_defaultClassIntrospector()

Overridable method for changing default SubtypeResolver instance to use

protected ContextAttributes
_defaultDefaultAttributes()

Overridable method for changing default ContextAttributes instance to use if not explicitly specified during build process.

protected TypeResolverBuilder<?>
_defaultDefaultTypingResolver(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, JsonTypeInfo.As includeAs)

Overridable method for changing default TypeResolverBuilder to construct for "default typing".

protected TypeResolverBuilder<?>
_defaultDefaultTypingResolver(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, String propertyName)

Overridable method for changing default TypeResolverBuilder to construct for "default typing".

protected DeserializationContexts
_defaultDeserializationContexts()

Overridable method for changing default SerializationContext prototype to use.

pack-priv DeserializerFactory
protected MixInHandler
_defaultMixInHandler()

Overridable method for changing default MixInHandler prototype to use.

protected PrettyPrinter
protected SerializationContexts
_defaultSerializationContexts()

Overridable method for changing default SerializationContext prototype to use.

protected SerializerFactory
protected SubtypeResolver
_defaultSubtypeResolver()

Overridable method for changing default SubtypeResolver prototype to use.

protected TypeFactory
_defaultTypeFactory()

Overridable method for changing default TypeFactory instance to use

protected TypeResolverProvider
_defaultTypeResolverProvider()

Overridable method for changing default TypeResolverProvider instance to use

protected abstract MapperBuilderState
protected final B
private void
public B

Returns:

Builder instance itself to allow chaining
accessorNaming
(AccessorNamingStrategy.Provider
Strategy instance to use; if null, use the default implementation
s
)

Method for configuring AccessorNamingStrategy to use for auto-detecting accessor ("getter") and mutator ("setter") methods based on naming of methods.

public B
activateDefaultTyping(PolymorphicTypeValidator subtypeValidator)

Convenience method that is equivalent to calling

  activateDefaultTyping(DefaultTyping.OBJECT_AND_NON_CONCRETE);
public B
activateDefaultTyping(PolymorphicTypeValidator subtypeValidator, DefaultTyping dti)

Convenience method that is equivalent to calling

  activateDefaultTyping(dti, JsonTypeInfo.As.WRAPPER_ARRAY);
public B
activateDefaultTyping(PolymorphicTypeValidator subtypeValidator, DefaultTyping
Defines kinds of types for which additional type information is added; see DefaultTyping for more information.
applicability
,
JsonTypeInfo.As includeAs)

Method for enabling automatic inclusion of type information, needed for proper deserialization of polymorphic types (unless types have been annotated with com.fasterxml.jackson.annotation.JsonTypeInfo).

public B
activateDefaultTypingAsProperty(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, String propertyName)

Method for enabling automatic inclusion of type information -- needed for proper deserialization of polymorphic types (unless types have been annotated with com.fasterxml.jackson.annotation.JsonTypeInfo) -- using "As.PROPERTY" inclusion mechanism and specified property name to use for inclusion (default being "@class" since default type information always uses class name as type identifier)

Note

choice of PolymorphicTypeValidator to configure is of crucial importance to security when deserializing untrusted content: this because allowing deserializing of any type can lead to malicious attacks using "deserialization gadgets".

public B
addAbstractTypeResolver(AbstractTypeResolver resolver)

Method for inserting specified AbstractTypeResolver as the first resolver in chain of possibly multiple resolvers.

public B
addHandler(DeserializationProblemHandler h)

Method used for adding a DeserializationProblemHandler for this builder, at the head of the list (meaning it has priority over handler registered earlier).

public B

Returns:

This builder instance to allow call chaining
addMixIn
(Class<?>
Target class on which to add annotations
target
,
Class<?>
Class that has annotations to add
mixinSource
)

Method to use for defining mix-in annotations to use for augmenting annotations that classes have, for purpose of configuration serialization and/or deserialization processing.

public B
addMixIns(Map<Class<?>, Class<?>> sourceMixins)

Method to use for defining mix-in annotations to use for augmenting annotations that processable (serializable / deserializable) classes have.

public B
addModule(JacksonModule module)

Method will add given module to be registered when mapper is built, possibly replacing an earlier instance of the module (as specified by its JacksonModule#getRegistrationId()).

public B
public B
addModules(Iterable<? extends JacksonModule> modules)

public B
public AnnotationIntrospector
public B
annotationIntrospector(AnnotationIntrospector intr)

Method for replacing AnnotationIntrospector used by the mapper instance to be built.

public BaseSettings
public B
public abstract M
build()

Method to call to create actual mapper instance.

public DeserializationConfig
public SerializationConfig
public B
public B
changeDefaultNullHandling(UnaryOperator<JsonSetter.Value> handler)

Method for changing currently default settings for handling of `null` values during deserialization, regarding whether they are set as-is, ignored completely, or possible transformed into "empty" value of the target type (if any).

public B
changeDefaultPropertyInclusion(UnaryOperator<JsonInclude.Value> handler)

Method for changing currently default settings for property inclusion, used for determining whether POJO properties with certain value should be excluded or not: most common case being exclusion of `null` values.

public B
changeDefaultVisibility(UnaryOperator<VisibilityChecker>
Function that is given current default visibility checker and that needs to return either checker as is, or a new instance created using one or more of withVisibility (and similar) calls.
handler
)

Method for changing currently configured default VisibilityChecker, object used for determining whether given property element (method, field, constructor) can be auto-detected or not.

public ClassIntrospector
public B
public B
clearProblemHandlers()

Method that may be used to remove all DeserializationProblemHandlers added to this builder (if any).

public B
configure(MapperFeature feature, boolean state)

public B
configure(SerializationFeature feature, boolean state)

public B
configure(DeserializationFeature feature, boolean state)

public B
configure(DatatypeFeature feature, boolean state)

public B
configure(StreamReadFeature feature, boolean state)

public B
configure(StreamWriteFeature feature, boolean state)

public B
configureForJackson2()

The builder returned uses default settings more closely matching the default configuration used in Jackson 2.x versions.

public B
constructorDetector(ConstructorDetector cd)

Method for specifying ConstructorDetector to use for determining some aspects of creator auto-detection (specifically auto-detection of constructor, and in particular behavior with single-argument constructors).

public DatatypeFeatures
public B
deactivateDefaultTyping()

Method for disabling automatic inclusion of type information; if so, only explicitly annotated types (ones with com.fasterxml.jackson.annotation.JsonTypeInfo) will have additional embedded type information.

public ContextAttributes
defaultAttributes()

Overridable method for changing default ContextAttributes instance to use if not explicitly specified during build process.

public B

Returns:

This Builder instance to allow call chaining
defaultAttributes
(ContextAttributes
Default instance to use, if not null, or null for "use empty default set".
attrs
)

Method for replacing default ContextAttributes that the mapper uses: usually one initialized with a set of default shared attributes, but potentially also with a custom implementation.

public B

Returns:

This mapper, for convenience to allow chaining
defaultBase64Variant
(Base64Variant
Base64 variant to use
v
)

Method that will configure default Base64Variant that byte[] serializers and deserializers will use.

public B
defaultDateFormat(DateFormat f)

Method for configuring the default DateFormat to use when serializing time values as Strings, and deserializing from JSON Strings.

public B
defaultLeniency(Boolean b)

Method for setting default Setter configuration, regarding things like merging, null-handling; used for properties for which there are no per-type or per-property overrides (via annotations or config overrides).

public B
defaultLocale(Locale locale)

Method for overriding default locale to use for formatting.

public B
defaultMergeable(Boolean b)

Method for setting default Setter configuration, regarding things like merging, null-handling; used for properties for which there are no per-type or per-property overrides (via annotations or config overrides).

public PrettyPrinter
public B
public B
defaultTimeZone(TimeZone tz)

Method for overriding default TimeZone to use for formatting.

public DeserializationContexts
public B
public LinkedNode<DeserializationProblemHandler>
public DeserializerFactory
public B
public B
disable(MapperFeature... features)

public B
public B
public B
disable(DatatypeFeature... features)

public B
public B
public B
enable(MapperFeature... features)

public B
public B
public B
enable(DatatypeFeature... features)

public B
public B
public B

Returns:

Builder instance itself to allow chaining
enumNamingStrategy
(EnumNamingStrategy
Strategy instance to use
s
)

Method for configuring EnumNamingStrategy to use for adapting POJO enum names (internal) into content property names (external)

public FilterProvider
public B
filterProvider(FilterProvider prov)

Method for configuring this mapper to use specified FilterProvider for mapping Filter Ids to actual filter instances.

public B
findAndAddModules()

Convenience method that is functionally equivalent to: addModules(builder.findModules());

As with findModules(), no caching is done for modules, so for performance reasons it may make sense to cache introspected set of modules if needed multiple times.

public B
findAndAddModules(ClassLoader cl)

Convenience method that is functionally equivalent to: addModules(builder.findModules(classLoader));

As with findModules(ClassLoader), no caching is done for modules, so for performance reasons it may make sense to cache introspected set of modules if needed multiple times.

public static List<JacksonModule>
findModules()

Method for locating available methods, using JDK ServiceLoader facility, along with module-provided SPI.

public static List<JacksonModule>
findModules(ClassLoader classLoader)

Method for locating available methods, using JDK ServiceLoader facility, along with module-provided SPI.

public B

Returns:

Builder instance itself to allow chaining
handlerInstantiator
(HandlerInstantiator
Instantiator to use; if null, use the default implementation
hi
)

Method for configuring HandlerInstantiator to use for creating instances of handlers (such as serializers, deserializers, type and type id resolvers), given a class.

public InjectableValues
public B
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public MixInHandler
public B
mixInHandler(MixInHandler h)

Method that may be used to completely change mix-in handling by providing alternate MixInHandler implementation.

public B
mixInOverrides(MixInResolver r)

Method that allows defining "override" mix-in resolver: something that is checked first, before simple mix-in definitions.

public B
public B
public B

Returns:

Builder instance itself to allow chaining
propertyNamingStrategy
(PropertyNamingStrategy
Strategy instance to use; if null, use the default implementation
s
)

Method for configuring PropertyNamingStrategy to use for adapting POJO property names (internal) into content property names (external)

public B
registerSubtypes(Class<?>... subtypes)

public B
public B
public B
removeAllModules()

Method that will drop all modules added (via addModule and similar calls) to this builder.

public B

Returns:

This builder instance to allow call chaining
removeMixIn
(Class<?>
Target class for which no mix-ins should remain after call
target
)

Method that allows making sure that specified target class does not have associated mix-in annotations: basically can be used to undo an earlier call to addMixIn.

public MapperBuilderState
saveStateApplyModules()

Method called by mapper being constructed to first save state (delegated to {code _saveState()} method), then apply modules (if any), and then return the saved state (but retain reference to it).

private static <T> ServiceLoader<T>
secureGetServiceLoader(final Class<T> clazz, final ClassLoader classLoader)

public SerializationContexts
public B
public SerializerFactory
public B
public B
setDefaultTyping(TypeResolverBuilder<?>
Type information inclusion handler
typer
)

Method for enabling automatic inclusion of type information, using specified handler object for determining which types this affects, as well as details of how information is embedded.

public TokenStreamFactory
public SubtypeResolver
public B
public TypeFactory
public B
public TypeResolverProvider
protected B
public B
withAllCoercionConfigs(Consumer<CoercionConfigs> handler)

Method for changing various aspects of configuration overrides.

public B
withAllConfigOverrides(Consumer<ConfigOverrides> handler)

Method for changing various aspects of configuration overrides.

public B
withCoercionConfig(LogicalType forType, Consumer<MutableCoercionConfig> handler)

Method for changing coercion config for specific logical types, through callback to specific handler.

public B
withCoercionConfig(Class<?> forType, Consumer<MutableCoercionConfig> handler)

Method for changing coercion config for specific physical type, through callback to specific handler.

public B
withCoercionConfigDefaults(Consumer<MutableCoercionConfig> handler)

Method for changing target-type-independent coercion configuration defaults.

public B
withConfigOverride(Class<?> forType, Consumer<MutableConfigOverride> handler)

Method for changing config overrides for specific type, through callback to specific handler.

public B
withModules(Consumer<JacksonModule> handler)

"Accessor" method that will expose set of registered modules, in addition order, using handler given.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait