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

java.lang.Object
tools.jackson.databind.cfg.MapperBuilder<M,B>
Direct Known Subclasses:
JsonMapper.Builder

public abstract class MapperBuilder<M extends ObjectMapper,B extends MapperBuilder<M,B>> extends Object
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 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

      protected static final PrettyPrinter DEFAULT_PRETTY_PRINTER
    • DEFAULT_ANNOTATION_INTROSPECTOR

      protected static final AnnotationIntrospector DEFAULT_ANNOTATION_INTROSPECTOR
    • DEFAULT_TYPE_VALIDATOR

      protected static final PolymorphicTypeValidator DEFAULT_TYPE_VALIDATOR
    • DEFAULT_ACCESSOR_NAMING

      protected static final AccessorNamingStrategy.Provider DEFAULT_ACCESSOR_NAMING
    • DEFAULT_BASE_SETTINGS

      protected static final BaseSettings DEFAULT_BASE_SETTINGS
    • DEFAULT_TYPE_RESOLVER_PROVIDER

      protected static final TypeResolverProvider DEFAULT_TYPE_RESOLVER_PROVIDER
    • NO_ABSTRACT_TYPE_RESOLVERS

      protected static final AbstractTypeResolver[] NO_ABSTRACT_TYPE_RESOLVERS
    • _baseSettings

      protected BaseSettings _baseSettings
    • _streamFactory

      protected TokenStreamFactory _streamFactory
      Underlying stream factory
    • _configOverrides

      protected final ConfigOverrides _configOverrides
      Various configuration setting overrides, both global base settings and per-class overrides.
    • _coercionConfigs

      protected final CoercionConfigs _coercionConfigs
      Coercion settings (global, per-type overrides)
    • _modules

      protected Map<Object,JacksonModule> _modules
      Modules registered for addition, indexed by registration id.
    • _typeFactory

      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)
    • _classIntrospector

      protected ClassIntrospector _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

      protected TypeResolverProvider _typeResolverProvider
      Entity responsible for construction actual type resolvers (TypeSerializers, TypeDeserializers).
    • _subtypeResolver

      protected SubtypeResolver _subtypeResolver
    • _mixInHandler

      protected MixInHandler _mixInHandler
      Handler responsible for resolving mix-in classes registered, if any.
    • _serializationContexts

      protected SerializationContexts _serializationContexts
      SerializationContexts to use as factory for stateful SerializationContexts
    • _serializerFactory

      protected SerializerFactory _serializerFactory
    • _filterProvider

      protected FilterProvider _filterProvider
    • _defaultPrettyPrinter

      protected PrettyPrinter _defaultPrettyPrinter
    • _deserializationContexts

      protected DeserializationContexts _deserializationContexts
      Factory to use for creating per-operation contexts.
    • _deserializerFactory

      protected DeserializerFactory _deserializerFactory
    • _injectableValues

      protected InjectableValues _injectableValues
      Provider for values to inject in deserialized POJOs.
    • _problemHandlers

      protected LinkedNode<DeserializationProblemHandler> _problemHandlers
      Optional handlers that application may register to try to work-around various problem situations during deserialization
    • _abstractTypeResolvers

      protected AbstractTypeResolver[] _abstractTypeResolvers
    • _defaultAttributes

      protected ContextAttributes _defaultAttributes
      Explicitly configured default ContextAttributes, if any.
    • _mapperFeatures

      protected long _mapperFeatures
      Set of shared mapper features enabled.
    • _serFeatures

      protected int _serFeatures
      Set of SerializationFeatures enabled.
    • _deserFeatures

      protected int _deserFeatures
      Set of DeserializationFeatures enabled.
    • _datatypeFeatures

      protected DatatypeFeatures _datatypeFeatures
    • _streamReadFeatures

      protected int _streamReadFeatures
      States of StreamReadFeatures to enable/disable.
    • _streamWriteFeatures

      protected int _streamWriteFeatures
      States of StreamWriteFeatures to enable/disable.
    • _formatReadFeatures

      protected int _formatReadFeatures
      Optional per-format parser feature flags.
    • _formatWriteFeatures

      protected int _formatWriteFeatures
      Optional per-format generator feature flags.
    • _savedState

      protected transient MapperBuilderState _savedState
      Configuration state after direct access, immediately before registration of modules (if any) and construction of actual mapper. Retained after first access, and returned from saveStateApplyModules(), to allow future "rebuild".
  • Constructor Details

    • MapperBuilder

      protected MapperBuilder(TokenStreamFactory streamFactory)
    • MapperBuilder

      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 Details

    • build

      public abstract M build()
      Method to call to create actual mapper instance.

      Implementation detail: usually construction occurs by passing this builder instance to constructor of specific mapper type builder builds.

    • saveStateApplyModules

      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). If method has been called previously, it will simply return retained state.
    • _constructModuleContext

      protected ModuleContextBase _constructModuleContext()
    • _saveState

      protected abstract MapperBuilderState _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

      public boolean isEnabled(MapperFeature f)
    • isEnabled

      public boolean isEnabled(DeserializationFeature f)
    • isEnabled

      public boolean isEnabled(SerializationFeature f)
    • isEnabled

      public boolean isEnabled(DatatypeFeature f)
    • isEnabled

      public boolean isEnabled(StreamReadFeature f)
    • isEnabled

      public boolean isEnabled(StreamWriteFeature f)
    • datatypeFeatures

      public DatatypeFeatures datatypeFeatures()
    • baseSettings

      public BaseSettings baseSettings()
    • streamFactory

      public TokenStreamFactory streamFactory()
    • annotationIntrospector

      public AnnotationIntrospector annotationIntrospector()
    • defaultAttributes

      public ContextAttributes defaultAttributes()
      Overridable method for changing default ContextAttributes instance to use if not explicitly specified during build process.
    • _defaultDefaultAttributes

      protected ContextAttributes _defaultDefaultAttributes()
      Overridable method for changing default ContextAttributes instance to use if not explicitly specified during build process.
    • typeFactory

      public TypeFactory typeFactory()
    • _defaultTypeFactory

      protected TypeFactory _defaultTypeFactory()
      Overridable method for changing default TypeFactory instance to use
    • classIntrospector

      public ClassIntrospector classIntrospector()
    • _defaultClassIntrospector

      protected ClassIntrospector _defaultClassIntrospector()
      Overridable method for changing default SubtypeResolver instance to use
    • typeResolverProvider

      public TypeResolverProvider typeResolverProvider()
    • _defaultTypeResolverProvider

      protected TypeResolverProvider _defaultTypeResolverProvider()
      Overridable method for changing default TypeResolverProvider instance to use
    • subtypeResolver

      public SubtypeResolver subtypeResolver()
    • _defaultSubtypeResolver

      protected SubtypeResolver _defaultSubtypeResolver()
      Overridable method for changing default SubtypeResolver prototype to use.
    • mixInHandler

      public MixInHandler mixInHandler()
    • _defaultMixInHandler

      protected MixInHandler _defaultMixInHandler()
      Overridable method for changing default MixInHandler prototype to use.
    • serializationContexts

      public SerializationContexts serializationContexts()
    • _defaultSerializationContexts

      protected SerializationContexts _defaultSerializationContexts()
      Overridable method for changing default SerializationContext prototype to use.
    • serializerFactory

      public SerializerFactory serializerFactory()
    • _defaultSerializerFactory

      protected SerializerFactory _defaultSerializerFactory()
    • filterProvider

      public FilterProvider filterProvider()
    • defaultPrettyPrinter

      public PrettyPrinter defaultPrettyPrinter()
    • _defaultPrettyPrinter

      protected PrettyPrinter _defaultPrettyPrinter()
    • deserializationContexts

      public DeserializationContexts deserializationContexts()
    • _defaultDeserializationContexts

      protected DeserializationContexts _defaultDeserializationContexts()
      Overridable method for changing default SerializationContext prototype to use.
    • deserializerFactory

      public DeserializerFactory deserializerFactory()
    • injectableValues

      public InjectableValues injectableValues()
    • deserializationProblemHandlers

      public LinkedNode<DeserializationProblemHandler> deserializationProblemHandlers()
    • enable

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

      public B disable(MapperFeature... features)
    • configure

      public B configure(MapperFeature feature, boolean state)
    • enable

      public B enable(SerializationFeature... features)
    • disable

      public B disable(SerializationFeature... features)
    • configure

      public B configure(SerializationFeature feature, boolean state)
    • enable

      public B enable(DeserializationFeature... features)
    • disable

      public B disable(DeserializationFeature... features)
    • configure

      public B configure(DeserializationFeature feature, boolean state)
    • enable

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

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

      public B configure(DatatypeFeature feature, boolean state)
    • configureForJackson2

      public B configureForJackson2()
      The builder returned uses default settings more closely matching the default configuration used in Jackson 2.x versions. It affects:

      This method is still a work in progress and may not yet fully replicate the default settings of Jackson 2.x.

    • enable

      public B enable(StreamReadFeature... features)
    • disable

      public B disable(StreamReadFeature... features)
    • configure

      public B configure(StreamReadFeature feature, boolean state)
    • enable

      public B enable(StreamWriteFeature... features)
    • disable

      public B disable(StreamWriteFeature... features)
    • configure

      public B configure(StreamWriteFeature feature, boolean state)
    • withConfigOverride

      public B withConfigOverride(Class<?> forType, Consumer<MutableConfigOverride> handler)
      Method for changing config overrides for specific type, through callback to specific handler.
    • withAllConfigOverrides

      public B withAllConfigOverrides(Consumer<ConfigOverrides> handler)
      Method for changing various aspects of configuration overrides.
    • changeDefaultVisibility

      public B changeDefaultVisibility(UnaryOperator<VisibilityChecker> 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. 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 of withVisibility (and similar) calls.
    • changeDefaultPropertyInclusion

      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.
    • changeDefaultNullHandling

      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).
    • defaultMergeable

      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).
    • defaultLeniency

      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).
    • withCoercionConfig

      public B withCoercionConfig(LogicalType forType, Consumer<MutableCoercionConfig> handler)
      Method for changing coercion config for specific logical types, through callback to specific handler.
    • withCoercionConfig

      public B withCoercionConfig(Class<?> forType, Consumer<MutableCoercionConfig> handler)
      Method for changing coercion config for specific physical type, through callback to specific handler.
    • withCoercionConfigDefaults

      public B withCoercionConfigDefaults(Consumer<MutableCoercionConfig> handler)
      Method for changing target-type-independent coercion configuration defaults.
    • withAllCoercionConfigs

      public B withAllCoercionConfigs(Consumer<CoercionConfigs> handler)
      Method for changing various aspects of configuration overrides.
    • removeAllModules

      public B removeAllModules()
      Method that will drop all modules added (via addModule(tools.jackson.databind.JacksonModule) and similar calls) to this builder.
    • addModule

      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()). Actual registration occurs in addition order (considering last add to count, in case of re-registration for same id) when build() is called.
    • addModules

      public B addModules(JacksonModule... modules)
    • addModules

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

      public static List<JacksonModule> findModules()
      Method for locating available methods, using JDK ServiceLoader facility, along with module-provided SPI.

      Note that method does not do any caching, so calls should be considered potentially expensive.

    • findModules

      public static List<JacksonModule> findModules(ClassLoader classLoader)
      Method for locating available methods, using JDK ServiceLoader facility, along with module-provided SPI.

      Note that method does not do any caching, so calls should be considered potentially expensive.

    • findAndAddModules

      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.

    • findAndAddModules

      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.

    • withModules

      public B withModules(Consumer<JacksonModule> handler)
      "Accessor" method that will expose set of registered modules, in addition order, using handler given.
    • baseSettings

      public B baseSettings(BaseSettings b)
    • annotationIntrospector

      public B annotationIntrospector(AnnotationIntrospector intr)
      Method for replacing AnnotationIntrospector used 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 at AnnotationIntrospectorPair.
      See Also:
    • defaultAttributes

      public B defaultAttributes(ContextAttributes 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.

      NOTE: instance specified will need to be thread-safe for usage, similar to the default (ContextAttributes.Impl).

      Parameters:
      attrs - Default instance to use, if not null, or null for "use empty default set".
      Returns:
      This Builder instance to allow call chaining
    • typeFactory

      public B typeFactory(TypeFactory f)
    • addTypeModifier

      public B addTypeModifier(TypeModifier modifier)
    • typeResolverProvider

      protected B typeResolverProvider(TypeResolverProvider p)
    • classIntrospector

      public B classIntrospector(ClassIntrospector ci)
    • subtypeResolver

      public B subtypeResolver(SubtypeResolver r)
    • polymorphicTypeValidator

      public B polymorphicTypeValidator(PolymorphicTypeValidator ptv)
    • handlerInstantiator

      public B handlerInstantiator(HandlerInstantiator hi)
      Method for configuring HandlerInstantiator to 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

      public B propertyNamingStrategy(PropertyNamingStrategy s)
      Method for configuring PropertyNamingStrategy to 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

      public B enumNamingStrategy(EnumNamingStrategy s)
      Method for configuring EnumNamingStrategy to 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

      public B accessorNaming(AccessorNamingStrategy.Provider s)
      Method for configuring AccessorNamingStrategy to 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

      public B serializerFactory(SerializerFactory f)
    • serializationContexts

      public B serializationContexts(SerializationContexts ctxt)
    • filterProvider

      public B filterProvider(FilterProvider prov)
      Method for configuring this mapper to use specified FilterProvider for 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 not ObjectWriters.

    • defaultPrettyPrinter

      public B defaultPrettyPrinter(PrettyPrinter pp)
    • deserializerFactory

      public B deserializerFactory(DeserializerFactory f)
    • deserializationContexts

      public B deserializationContexts(DeserializationContexts ctxt)
    • injectableValues

      public B injectableValues(InjectableValues v)
    • nodeFactory

      public B nodeFactory(JsonNodeFactory f)
    • constructorDetector

      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).
    • cacheProvider

      public B cacheProvider(CacheProvider cacheProvider)
    • addHandler

      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).
    • clearProblemHandlers

      public B clearProblemHandlers()
      Method that may be used to remove all DeserializationProblemHandlers added to this builder (if any).
    • addAbstractTypeResolver

      public B addAbstractTypeResolver(AbstractTypeResolver resolver)
      Method for inserting specified AbstractTypeResolver as the first resolver in chain of possibly multiple resolvers.
    • defaultDateFormat

      public B defaultDateFormat(DateFormat f)
      Method for configuring the default DateFormat to use when serializing time values as Strings, and deserializing from JSON Strings. If you need per-request configuration, factory methods in ObjectReader and ObjectWriter instead.
    • defaultTimeZone

      public B defaultTimeZone(TimeZone tz)
      Method for overriding default TimeZone to use for formatting. Default value used is UTC (NOT default TimeZone of JVM).
    • defaultLocale

      public B defaultLocale(Locale locale)
      Method for overriding default locale to use for formatting. Default value used is Locale.getDefault().
    • defaultBase64Variant

      public B defaultBase64Variant(Base64Variant v)
      Method that will configure default Base64Variant that byte[] serializers and deserializers will use.
      Parameters:
      v - Base64 variant to use
      Returns:
      This mapper, for convenience to allow chaining
    • mixInHandler

      public B mixInHandler(MixInHandler h)
      Method that may be used to completely change mix-in handling by providing alternate MixInHandler implementation. Most of the time this is NOT the method you want to call, and rather are looking for mixInOverrides(tools.jackson.databind.introspect.MixInResolver).
    • mixInOverrides

      public B mixInOverrides(MixInResolver r)
      Method that allows defining "override" mix-in resolver: something that is checked first, before simple mix-in definitions.
    • addMixIns

      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. This convenience method is equivalent to iterating over all entries and calling addMixIn(java.lang.Class<?>, java.lang.Class<?>) with `key` and `value` of each entry.
    • addMixIn

      public B addMixIn(Class<?> target, Class<?> 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. 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 mixinSource of null (although preferred mechanism is removeMixIn(java.lang.Class<?>))

      Parameters:
      target - Target class on which to add annotations
      mixinSource - Class that has annotations to add
      Returns:
      This builder instance to allow call chaining
    • removeMixIn

      public B removeMixIn(Class<?> 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(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

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

      public B registerSubtypes(NamedType... subtypes)
    • registerSubtypes

      public B registerSubtypes(Collection<Class<?>> subtypes)
    • activateDefaultTyping

      public B activateDefaultTyping(PolymorphicTypeValidator subtypeValidator)
      Convenience method that is equivalent to calling
        activateDefaultTyping(DefaultTyping.OBJECT_AND_NON_CONCRETE);
      

      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". 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 dti)
      Convenience method that is equivalent to calling
        activateDefaultTyping(dti, JsonTypeInfo.As.WRAPPER_ARRAY);
      

      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". 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 with JsonTypeInfo).

      NOTE: use of JsonTypeInfo.As#EXTERNAL_PROPERTY NOT SUPPORTED; and attempts of do so will throw an IllegalArgumentException to make this limitation explicit.

      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". 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; see DefaultTyping for 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 with 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". Implementations should use allow-listing to specify acceptable types unless source of content is fully trusted to only send safe types.

    • deactivateDefaultTyping

      public B deactivateDefaultTyping()
      Method for disabling automatic inclusion of type information; if so, only explicitly annotated types (ones with JsonTypeInfo) will have additional embedded type information.
    • setDefaultTyping

      public B 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.

      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 TypeResolverBuilder that 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 default TypeResolverBuilder to construct for "default typing".
    • _defaultDefaultTypingResolver

      protected TypeResolverBuilder<?> _defaultDefaultTypingResolver(PolymorphicTypeValidator subtypeValidator, DefaultTyping applicability, String propertyName)
      Overridable method for changing default TypeResolverBuilder to construct for "default typing".
    • _this

      protected final B _this()