Class MapperBuilder<M extends ObjectMapper,B extends MapperBuilder<M,B>>
- Direct Known Subclasses:
JsonMapper.Builder
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
FieldsModifier and TypeFieldDescriptionprotected AbstractTypeResolver[]protected BaseSettingsprotected ClassIntrospectorIntrospector used to figure out Bean properties needed for bean serialization and deserialization.protected final CoercionConfigsCoercion settings (global, per-type overrides)protected final ConfigOverridesVarious configuration setting overrides, both global base settings and per-class overrides.protected DatatypeFeaturesprotected ContextAttributesExplicitly configured defaultContextAttributes, if any.protected PrettyPrinterprotected intSet ofDeserializationFeatures enabled.protected DeserializationContextsFactory to use for creating per-operation contexts.protected DeserializerFactoryprotected FilterProviderprotected intOptional per-format parser feature flags.protected intOptional per-format generator feature flags.protected InjectableValuesProvider for values to inject in deserialized POJOs.protected longSet of shared mapper features enabled.protected MixInHandlerHandler responsible for resolving mix-in classes registered, if any.protected Map<Object,JacksonModule> Modules registered for addition, indexed by registration id.protected LinkedNode<DeserializationProblemHandler>Optional handlers that application may register to try to work-around various problem situations during deserializationprotected MapperBuilderStateConfiguration state after direct access, immediately before registration of modules (if any) and construction of actual mapper.protected intSet ofSerializationFeatures enabled.protected SerializationContextsSerializationContextsto use as factory for statefulSerializationContextsprotected SerializerFactoryprotected TokenStreamFactoryUnderlying stream factoryprotected intStates ofStreamReadFeatures to enable/disable.protected intStates ofStreamWriteFeatures to enable/disable.protected SubtypeResolverprotected TypeFactorySpecific factory used for creatingJavaTypeinstances; needed to allow modules to add more custom type handling (mostly to support types of non-Java JVM languages)protected TypeResolverProviderEntity responsible for construction actual type resolvers (TypeSerializers,TypeDeserializers).protected static final AccessorNamingStrategy.Providerprotected static final AnnotationIntrospectorprotected static final BaseSettingsprotected static final intprotected static final longprotected static final PrettyPrinterprotected static final intprotected static final TypeResolverProviderprotected static final PolymorphicTypeValidatorprotected static final AbstractTypeResolver[] -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMapperBuilder(TokenStreamFactory streamFactory) protectedMapperBuilder(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 TypeMethodDescriptionprotected ModuleContextBaseprotected ClassIntrospectorOverridable method for changing defaultSubtypeResolverinstance to useprotected ContextAttributesOverridable method for changing defaultContextAttributesinstance to use if not explicitly specified during build process.protected TypeResolverBuilder<?>_defaultDefaultTypingResolver(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, JsonTypeInfo.As includeAs) Overridable method for changing defaultTypeResolverBuilderto construct for "default typing".protected TypeResolverBuilder<?>_defaultDefaultTypingResolver(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, String propertyName) Overridable method for changing defaultTypeResolverBuilderto construct for "default typing".protected DeserializationContextsOverridable method for changing defaultSerializationContextprototype to use.protected MixInHandlerOverridable method for changing defaultMixInHandlerprototype to use.protected PrettyPrinterprotected SerializationContextsOverridable method for changing defaultSerializationContextprototype to use.protected SerializerFactoryprotected SubtypeResolverOverridable method for changing defaultSubtypeResolverprototype to use.protected TypeFactoryOverridable method for changing defaultTypeFactoryinstance to useprotected TypeResolverProviderOverridable method for changing defaultTypeResolverProviderinstance to useprotected abstract MapperBuilderStateprotected final B_this()Method for configuringAccessorNamingStrategyto use for auto-detecting accessor ("getter") and mutator ("setter") methods based on naming of methods.activateDefaultTyping(PolymorphicTypeValidator subtypeValidator) Convenience method that is equivalent to callingactivateDefaultTyping(PolymorphicTypeValidator subtypeValidator, DefaultTyping dti) Convenience method that is equivalent to callingactivateDefaultTyping(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, JsonTypeInfo.As includeAs) Method for enabling automatic inclusion of type information, needed for proper deserialization of polymorphic types (unless types have been annotated withJsonTypeInfo).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 withJsonTypeInfo) -- 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)addAbstractTypeResolver(AbstractTypeResolver resolver) Method for inserting specifiedAbstractTypeResolveras the first resolver in chain of possibly multiple resolvers.Method used for adding aDeserializationProblemHandlerfor this builder, at the head of the list (meaning it has priority over handler registered earlier).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.Method to use for defining mix-in annotations to use for augmenting annotations that processable (serializable / deserializable) classes have.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 itsJacksonModule.getRegistrationId()).addModules(Iterable<? extends JacksonModule> modules) addModules(JacksonModule... modules) addTypeModifier(TypeModifier modifier) Method for replacingAnnotationIntrospectorused by the mapper instance to be built.abstract Mbuild()Method to call to create actual mapper instance.buildDeserializationConfig(ConfigOverrides configOverrides, MixInHandler mixins, TypeFactory tf, ClassIntrospector classIntr, SubtypeResolver str, RootNameLookup rootNames, CoercionConfigs coercionConfigs) buildSerializationConfig(ConfigOverrides configOverrides, MixInHandler mixins, TypeFactory tf, ClassIntrospector classIntr, SubtypeResolver str, RootNameLookup rootNames, FilterProvider filterProvider) cacheProvider(CacheProvider cacheProvider) 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).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.Method for changing currently configured defaultVisibilityChecker, object used for determining whether given property element (method, field, constructor) can be auto-detected or not.Method that may be used to remove allDeserializationProblemHandlers added to this builder (if any).configure(StreamReadFeature feature, boolean state) configure(StreamWriteFeature feature, boolean state) configure(DatatypeFeature feature, boolean state) configure(DeserializationFeature feature, boolean state) configure(MapperFeature feature, boolean state) configure(SerializationFeature feature, boolean state) The builder returned uses default settings more closely matching the default configs used in Jackson 2.x versions.Method for specifyingConstructorDetectorto use for determining some aspects of creator auto-detection (specifically auto-detection of constructor, and in particular behavior with single-argument constructors).Method for disabling automatic inclusion of type information; if so, only explicitly annotated types (ones withJsonTypeInfo) will have additional embedded type information.Overridable method for changing defaultContextAttributesinstance to use if not explicitly specified during build process.Method for replacing defaultContextAttributesthat the mapper uses: usually one initialized with a set of default shared attributes, but potentially also with a custom implementation.Method that will configure defaultBase64Variantthatbyte[]serializers and deserializers will use.Method for configuring the defaultDateFormatto use when serializing time values as Strings, and deserializing from JSON Strings.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).defaultLocale(Locale locale) Method for overriding default locale to use for formatting.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).Method for overriding default TimeZone to use for formatting.disable(StreamReadFeature... features) disable(StreamWriteFeature... features) disable(DatatypeFeature... features) disable(DeserializationFeature... features) disable(MapperFeature... features) disable(SerializationFeature... features) enable(StreamReadFeature... features) enable(StreamWriteFeature... features) enable(DatatypeFeature... features) enable(DeserializationFeature... features) enable(MapperFeature... features) enable(SerializationFeature... features) Method for configuringEnumNamingStrategyto use for adapting POJO enum names (internal) into content property names (external)filterProvider(FilterProvider prov) Method for configuring this mapper to use specifiedFilterProviderfor mapping Filter Ids to actual filter instances.Convenience method that is functionally equivalent to:addModules(builder.findModules());Convenience method that is functionally equivalent to:addModules(builder.findModules(classLoader));static List<JacksonModule>Method for locating available methods, using JDKServiceLoaderfacility, along with module-provided SPI.static List<JacksonModule>findModules(ClassLoader classLoader) Method for locating available methods, using JDKServiceLoaderfacility, along with module-provided SPI.Method for configuringHandlerInstantiatorto use for creating instances of handlers (such as serializers, deserializers, type and type id resolvers), given a class.booleanbooleanbooleanbooleanbooleanbooleanMethod that may be used to completely change mix-in handling by providing alternateMixInHandlerimplementation.Method that allows defining "override" mix-in resolver: something that is checked first, before simple mix-in definitions.Method for configuringPropertyNamingStrategyto use for adapting POJO property names (internal) into content property names (external)registerSubtypes(Class<?>... subtypes) registerSubtypes(Collection<Class<?>> subtypes) registerSubtypes(NamedType... subtypes) Method that will drop all modules added (viaaddModule(tools.jackson.databind.JacksonModule)and similar calls) to this builder.removeMixIn(Class<?> target) Method that allows making sure that specifiedtargetclass does not have associated mix-in annotations: basically can be used to undo an earlier call toaddMixIn(java.lang.Class<?>, java.lang.Class<?>).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).setDefaultTyping(TypeResolverBuilder<?> 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.protected BwithAllCoercionConfigs(Consumer<CoercionConfigs> handler) Method for changing various aspects of configuration overrides.withAllConfigOverrides(Consumer<ConfigOverrides> handler) Method for changing various aspects of configuration overrides.withCoercionConfig(Class<?> forType, Consumer<MutableCoercionConfig> handler) Method for changing coercion config for specific physical type, through callback to specific handler.withCoercionConfig(LogicalType forType, Consumer<MutableCoercionConfig> handler) Method for changing coercion config for specific logical types, through callback to specific handler.Method for changing target-type-independent coercion configuration defaults.withConfigOverride(Class<?> forType, Consumer<MutableConfigOverride> handler) Method for changing config overrides for specific type, through callback to specific handler.withModules(Consumer<JacksonModule> handler) "Accessor" method that will expose set of registered modules, in addition order, usinghandlergiven.
-
Field Details
-
DEFAULT_MAPPER_FEATURES
protected static final long DEFAULT_MAPPER_FEATURES -
DEFAULT_SER_FEATURES
protected static final int DEFAULT_SER_FEATURES -
DEFAULT_DESER_FEATURES
protected static final int DEFAULT_DESER_FEATURES -
DEFAULT_PRETTY_PRINTER
-
DEFAULT_ANNOTATION_INTROSPECTOR
-
DEFAULT_TYPE_VALIDATOR
-
DEFAULT_ACCESSOR_NAMING
-
DEFAULT_BASE_SETTINGS
-
DEFAULT_TYPE_RESOLVER_PROVIDER
-
NO_ABSTRACT_TYPE_RESOLVERS
-
_baseSettings
-
_streamFactory
Underlying stream factory -
_configOverrides
Various configuration setting overrides, both global base settings and per-class overrides. -
_coercionConfigs
Coercion settings (global, per-type overrides) -
_modules
Modules registered for addition, indexed by registration id. -
_typeFactory
Specific factory used for creatingJavaTypeinstances; needed to allow modules to add more custom type handling (mostly to support types of non-Java JVM languages) -
_classIntrospector
Introspector used to figure out Bean properties needed for bean serialization and deserialization. Overridable so that it is possible to change low-level details of introspection, like adding new annotation types. -
_typeResolverProvider
Entity responsible for construction actual type resolvers (TypeSerializers,TypeDeserializers). -
_subtypeResolver
-
_mixInHandler
Handler responsible for resolving mix-in classes registered, if any. -
_serializationContexts
SerializationContextsto use as factory for statefulSerializationContexts -
_serializerFactory
-
_filterProvider
-
_defaultPrettyPrinter
-
_deserializationContexts
Factory to use for creating per-operation contexts. -
_deserializerFactory
-
_injectableValues
Provider for values to inject in deserialized POJOs. -
_problemHandlers
Optional handlers that application may register to try to work-around various problem situations during deserialization -
_abstractTypeResolvers
-
_defaultAttributes
Explicitly configured defaultContextAttributes, if any. -
_mapperFeatures
protected long _mapperFeaturesSet of shared mapper features enabled. -
_serFeatures
protected int _serFeaturesSet ofSerializationFeatures enabled. -
_deserFeatures
protected int _deserFeaturesSet ofDeserializationFeatures enabled. -
_datatypeFeatures
-
_streamReadFeatures
protected int _streamReadFeaturesStates ofStreamReadFeatures to enable/disable. -
_streamWriteFeatures
protected int _streamWriteFeaturesStates ofStreamWriteFeatures to enable/disable. -
_formatReadFeatures
protected int _formatReadFeaturesOptional per-format parser feature flags. -
_formatWriteFeatures
protected int _formatWriteFeaturesOptional per-format generator feature flags. -
_savedState
Configuration state after direct access, immediately before registration of modules (if any) and construction of actual mapper. Retained after first access, and returned fromsaveStateApplyModules(), to allow future "rebuild".
-
-
Constructor Details
-
MapperBuilder
-
MapperBuilder
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 Details
-
build
Method to call to create actual mapper instance.Implementation detail: usually construction occurs by passing
thisbuilder instance to constructor of specific mapper type builder builds. -
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). If method has been called previously, it will simply return retained state. -
_constructModuleContext
-
_saveState
-
buildSerializationConfig
public SerializationConfig buildSerializationConfig(ConfigOverrides configOverrides, MixInHandler mixins, TypeFactory tf, ClassIntrospector classIntr, SubtypeResolver str, RootNameLookup rootNames, FilterProvider filterProvider) -
buildDeserializationConfig
public DeserializationConfig buildDeserializationConfig(ConfigOverrides configOverrides, MixInHandler mixins, TypeFactory tf, ClassIntrospector classIntr, SubtypeResolver str, RootNameLookup rootNames, CoercionConfigs coercionConfigs) -
isEnabled
-
isEnabled
-
isEnabled
-
isEnabled
-
isEnabled
-
isEnabled
-
datatypeFeatures
-
baseSettings
-
streamFactory
-
annotationIntrospector
-
defaultAttributes
Overridable method for changing defaultContextAttributesinstance to use if not explicitly specified during build process. -
_defaultDefaultAttributes
Overridable method for changing defaultContextAttributesinstance to use if not explicitly specified during build process. -
typeFactory
-
_defaultTypeFactory
Overridable method for changing defaultTypeFactoryinstance to use -
classIntrospector
-
_defaultClassIntrospector
Overridable method for changing defaultSubtypeResolverinstance to use -
typeResolverProvider
-
_defaultTypeResolverProvider
Overridable method for changing defaultTypeResolverProviderinstance to use -
subtypeResolver
-
_defaultSubtypeResolver
Overridable method for changing defaultSubtypeResolverprototype to use. -
mixInHandler
-
_defaultMixInHandler
Overridable method for changing defaultMixInHandlerprototype to use. -
serializationContexts
-
_defaultSerializationContexts
Overridable method for changing defaultSerializationContextprototype to use. -
serializerFactory
-
_defaultSerializerFactory
-
filterProvider
-
defaultPrettyPrinter
-
_defaultPrettyPrinter
-
deserializationContexts
-
_defaultDeserializationContexts
Overridable method for changing defaultSerializationContextprototype to use. -
deserializerFactory
-
injectableValues
-
deserializationProblemHandlers
-
enable
-
disable
-
configure
-
enable
-
disable
-
configure
-
enable
-
disable
-
configure
-
enable
-
disable
-
configure
-
configureForJackson2
The builder returned uses default settings more closely matching the default configs used in Jackson 2.x versions.This method is still a work in progress and may not yet fully replicate the default settings of Jackson 2.x.
-
enable
-
disable
-
configure
-
enable
-
disable
-
configure
-
withConfigOverride
Method for changing config overrides for specific type, through callback to specific handler. -
withAllConfigOverrides
Method for changing various aspects of configuration overrides. -
changeDefaultVisibility
Method for changing currently configured defaultVisibilityChecker, object used for determining whether given property element (method, field, constructor) can be auto-detected or not. Checker to modify is used for all POJO types for which there is no specific per-type checker.- Parameters:
handler- 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 ofwithVisibility(and similar) calls.
-
changeDefaultPropertyInclusion
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. -
changeDefaultNullHandling
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). -
defaultMergeable
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). -
defaultLeniency
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). -
withCoercionConfig
Method for changing coercion config for specific logical types, through callback to specific handler. -
withCoercionConfig
Method for changing coercion config for specific physical type, through callback to specific handler. -
withCoercionConfigDefaults
Method for changing target-type-independent coercion configuration defaults. -
withAllCoercionConfigs
Method for changing various aspects of configuration overrides. -
removeAllModules
Method that will drop all modules added (viaaddModule(tools.jackson.databind.JacksonModule)and similar calls) to this builder. -
addModule
Method will add given module to be registered when mapper is built, possibly replacing an earlier instance of the module (as specified by itsJacksonModule.getRegistrationId()). Actual registration occurs in addition order (considering last add to count, in case of re-registration for same id) whenbuild()is called. -
addModules
-
addModules
-
findModules
Method for locating available methods, using JDKServiceLoaderfacility, along with module-provided SPI.Note that method does not do any caching, so calls should be considered potentially expensive.
-
findModules
Method for locating available methods, using JDKServiceLoaderfacility, along with module-provided SPI.Note that method does not do any caching, so calls should be considered potentially expensive.
-
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. -
findAndAddModules
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. -
withModules
"Accessor" method that will expose set of registered modules, in addition order, usinghandlergiven. -
baseSettings
-
annotationIntrospector
Method for replacingAnnotationIntrospectorused by the mapper instance to be built. Note that doing this will replace the current introspector, which may lead to unavailability of core Jackson annotations. If you want to combine handling of multiple introspectors, have a look atAnnotationIntrospectorPair.- See Also:
-
defaultAttributes
Method for replacing defaultContextAttributesthat the mapper uses: usually one initialized with a set of default shared attributes, but potentially also with a custom implementation.NOTE: instance specified will need to be thread-safe for usage, similar to the default (
ContextAttributes.Impl).- Parameters:
attrs- Default instance to use, if notnull, ornullfor "use empty default set".- Returns:
- This Builder instance to allow call chaining
-
typeFactory
-
addTypeModifier
-
typeResolverProvider
-
classIntrospector
-
subtypeResolver
-
polymorphicTypeValidator
-
handlerInstantiator
Method for configuringHandlerInstantiatorto use for creating instances of handlers (such as serializers, deserializers, type and type id resolvers), given a class.- Parameters:
hi- Instantiator to use; if null, use the default implementation- Returns:
- Builder instance itself to allow chaining
-
propertyNamingStrategy
Method for configuringPropertyNamingStrategyto use for adapting POJO property names (internal) into content property names (external)- Parameters:
s- Strategy instance to use; if null, use the default implementation- Returns:
- Builder instance itself to allow chaining
-
enumNamingStrategy
Method for configuringEnumNamingStrategyto use for adapting POJO enum names (internal) into content property names (external)- Parameters:
s- Strategy instance to use- Returns:
- Builder instance itself to allow chaining
-
accessorNaming
Method for configuringAccessorNamingStrategyto use for auto-detecting accessor ("getter") and mutator ("setter") methods based on naming of methods.- Parameters:
s- Strategy instance to use; if null, use the default implementation- Returns:
- Builder instance itself to allow chaining
-
serializerFactory
-
serializationContexts
-
filterProvider
Method for configuring this mapper to use specifiedFilterProviderfor mapping Filter Ids to actual filter instances.Note that usually it is better to use method in
ObjectWriter, but sometimes this method is more convenient. For example, some frameworks only allow configuring of ObjectMapper instances and notObjectWriters. -
defaultPrettyPrinter
-
deserializerFactory
-
deserializationContexts
-
injectableValues
-
nodeFactory
-
constructorDetector
Method for specifyingConstructorDetectorto use for determining some aspects of creator auto-detection (specifically auto-detection of constructor, and in particular behavior with single-argument constructors). -
cacheProvider
-
addHandler
Method used for adding aDeserializationProblemHandlerfor this builder, at the head of the list (meaning it has priority over handler registered earlier). -
clearProblemHandlers
Method that may be used to remove allDeserializationProblemHandlers added to this builder (if any). -
addAbstractTypeResolver
Method for inserting specifiedAbstractTypeResolveras the first resolver in chain of possibly multiple resolvers. -
defaultDateFormat
Method for configuring the defaultDateFormatto use when serializing time values as Strings, and deserializing from JSON Strings. If you need per-request configuration, factory methods inObjectReaderandObjectWriterinstead. -
defaultTimeZone
Method for overriding default TimeZone to use for formatting. Default value used is UTC (NOT default TimeZone of JVM). -
defaultLocale
Method for overriding default locale to use for formatting. Default value used isLocale.getDefault(). -
defaultBase64Variant
Method that will configure defaultBase64Variantthatbyte[]serializers and deserializers will use.- Parameters:
v- Base64 variant to use- Returns:
- This mapper, for convenience to allow chaining
-
mixInHandler
Method that may be used to completely change mix-in handling by providing alternateMixInHandlerimplementation. Most of the time this is NOT the method you want to call, and rather are looking formixInOverrides(tools.jackson.databind.introspect.MixInResolver). -
mixInOverrides
Method that allows defining "override" mix-in resolver: something that is checked first, before simple mix-in definitions. -
addMixIns
Method to use for defining mix-in annotations to use for augmenting annotations that processable (serializable / deserializable) classes have. This convenience method is equivalent to iterating over all entries and callingaddMixIn(java.lang.Class<?>, java.lang.Class<?>)with `key` and `value` of each entry. -
addMixIn
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. Mixing in is done when introspecting class annotations and properties. Annotations from "mixin" class (and its supertypes) will override annotations that target classes (and their super-types) have.Note that standard mixin handler implementations will only allow a single mix-in source class per target, so if there was a previous mix-in defined target it will be cleared. This also means that you can remove mix-in definition by specifying
mixinSourceofnull(although preferred mechanism isremoveMixIn(java.lang.Class<?>))- Parameters:
target- Target class on which to add annotationsmixinSource- Class that has annotations to add- Returns:
- This builder instance to allow call chaining
-
removeMixIn
Method that allows making sure that specifiedtargetclass does not have associated mix-in annotations: basically can be used to undo an earlier call toaddMixIn(java.lang.Class<?>, java.lang.Class<?>).NOTE: removing mix-ins for given class does not try to remove possible mix-ins for any of its super classes and super interfaces; only direct mix-in addition, if any, is removed.
- Parameters:
target- Target class for which no mix-ins should remain after call- Returns:
- This builder instance to allow call chaining
-
registerSubtypes
-
registerSubtypes
-
registerSubtypes
-
activateDefaultTyping
Convenience method that is equivalent to callingactivateDefaultTyping(DefaultTyping.OBJECT_AND_NON_CONCRETE);
NOTE: choice of
PolymorphicTypeValidatorto 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". Implementations should use allow-listing to specify acceptable types unless source of content is fully trusted to only send safe types. -
activateDefaultTyping
Convenience method that is equivalent to callingactivateDefaultTyping(dti, JsonTypeInfo.As.WRAPPER_ARRAY);
NOTE: choice of
PolymorphicTypeValidatorto 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". Implementations should use allow-listing to specify acceptable types unless source of content is fully trusted to only send safe types. -
activateDefaultTyping
public B activateDefaultTyping(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, JsonTypeInfo.As includeAs) Method for enabling automatic inclusion of type information, needed for proper deserialization of polymorphic types (unless types have been annotated withJsonTypeInfo).NOTE: use of
JsonTypeInfo.As#EXTERNAL_PROPERTYNOT SUPPORTED; and attempts of do so will throw anIllegalArgumentExceptionto make this limitation explicit.NOTE: choice of
PolymorphicTypeValidatorto 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". Implementations should use allow-listing to specify acceptable types unless source of content is fully trusted to only send safe types.- Parameters:
applicability- Defines kinds of types for which additional type information is added; seeDefaultTypingfor more information.
-
activateDefaultTypingAsProperty
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 withJsonTypeInfo) -- 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
PolymorphicTypeValidatorto 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". Implementations should use allow-listing to specify acceptable types unless source of content is fully trusted to only send safe types. -
deactivateDefaultTyping
Method for disabling automatic inclusion of type information; if so, only explicitly annotated types (ones withJsonTypeInfo) will have additional embedded type information. -
setDefaultTyping
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.NOTE: use of Default Typing can be a potential security risk if incoming content comes from untrusted sources, so care should be taken to use a
TypeResolverBuilderthat can limit allowed classes to deserialize.- Parameters:
typer- Type information inclusion handler
-
_defaultDefaultTypingResolver
protected TypeResolverBuilder<?> _defaultDefaultTypingResolver(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, JsonTypeInfo.As includeAs) Overridable method for changing defaultTypeResolverBuilderto construct for "default typing". -
_defaultDefaultTypingResolver
protected TypeResolverBuilder<?> _defaultDefaultTypingResolver(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, String propertyName) Overridable method for changing defaultTypeResolverBuilderto construct for "default typing". -
_this
-