Interface TypeResolverBuilder<T extends TypeResolverBuilder<T>>
- All Known Implementing Classes:
DefaultTypeResolverBuilder,StdTypeResolverBuilder
JsonTypeInfo or JAXB annotations),
and produce type serializers and deserializers used for
handling type information embedded in JSON to allow for safe
polymorphic type handling.
Builder is first initialized by calling init(com.fasterxml.jackson.annotation.JsonTypeInfo.Value, tools.jackson.databind.jsontype.TypeIdResolver) method.
Finally, after calling all configuration methods,
buildTypeSerializer(tools.jackson.databind.SerializationContext, tools.jackson.databind.JavaType, java.util.Collection<tools.jackson.databind.jsontype.NamedType>) or buildTypeDeserializer(tools.jackson.databind.DeserializationContext, tools.jackson.databind.JavaType, java.util.Collection<tools.jackson.databind.jsontype.NamedType>)
will be called to get actual type resolver constructed
and used for resolving types for configured base type and its
subtypes.
Note that instances are used for two related but distinct use cases:
- To create builders to use with explicit type information
inclusion (usually via
@JsonTypeInfoannotation) - To create builders when "default typing" is used; if so, type information is automatically included for certain kind of types, regardless of annotations
-
Method Summary
Modifier and TypeMethodDescriptionbuildTypeDeserializer(DeserializationContext ctxt, JavaType baseType, Collection<NamedType> subtypes) Method for building type deserializer based on current configuration of this builder.buildTypeSerializer(SerializationContext ctxt, JavaType baseType, Collection<NamedType> subtypes) Method for building type serializer based on current configuration of this builder.Class<?>Accessor for currently configured default type; implementation class that may be used in case no valid type information is available during type resolutioninit(JsonTypeInfo.Value settings, TypeIdResolver res) Initialization method that is called right after constructing the builder instance, in cases where information could not be passed directly (for example when instantiated for an annotation)withDefaultImpl(Class<?> defaultImpl) "Mutant factory" method for creating a new instance with different default implementation to use if type id is either not available, or cannot be resolved.withSettings(JsonTypeInfo.Value typeInfo) Method for overriding type information.
-
Method Details
-
getDefaultImpl
Class<?> getDefaultImpl()Accessor for currently configured default type; implementation class that may be used in case no valid type information is available during type resolution -
buildTypeSerializer
TypeSerializer buildTypeSerializer(SerializationContext ctxt, JavaType baseType, Collection<NamedType> subtypes) Method for building type serializer based on current configuration of this builder.- Parameters:
baseType- Base type that constructed resolver will handle; super type of all types it will be used for.
-
buildTypeDeserializer
TypeDeserializer buildTypeDeserializer(DeserializationContext ctxt, JavaType baseType, Collection<NamedType> subtypes) Method for building type deserializer based on current configuration of this builder.- Parameters:
baseType- Base type that constructed resolver will handle; super type of all types it will be used for.subtypes- Known subtypes of the base type.
-
init
Initialization method that is called right after constructing the builder instance, in cases where information could not be passed directly (for example when instantiated for an annotation)- Parameters:
settings- Configuration settings to apply.- Returns:
- Resulting builder instance (usually this builder, but not necessarily)
-
withDefaultImpl
"Mutant factory" method for creating a new instance with different default implementation to use if type id is either not available, or cannot be resolved.In Jackson 2.x there was instead method
defaultImpl()which was a mutator: this method MUST NOT change the underlying state.- Returns:
- Either this instance (if nothing changed) or a new instance with different default implementation
-
withSettings
Method for overriding type information.
-