public interface TypeResolverBuilder<T extends TypeResolverBuilder<T>>
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.Id, com.fasterxml.jackson.databind.jsontype.TypeIdResolver)
method, and then
configured using 'set' methods like inclusion(com.fasterxml.jackson.annotation.JsonTypeInfo.As)
.
Finally, after calling all configuration methods,
buildTypeSerializer(com.fasterxml.jackson.databind.SerializationConfig, com.fasterxml.jackson.databind.JavaType, java.util.Collection<com.fasterxml.jackson.databind.jsontype.NamedType>)
or buildTypeDeserializer(com.fasterxml.jackson.databind.DeserializationConfig, com.fasterxml.jackson.databind.JavaType, java.util.Collection<com.fasterxml.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:
@JsonTypeInfo
annotation)
Modifier and Type | Method and Description |
---|---|
TypeDeserializer |
buildTypeDeserializer(DeserializationConfig config,
JavaType baseType,
Collection<NamedType> subtypes)
Method for building type deserializer based on current configuration
of this builder.
|
TypeSerializer |
buildTypeSerializer(SerializationConfig config,
JavaType baseType,
Collection<NamedType> subtypes)
Method for building type serializer based on current configuration
of this builder.
|
T |
defaultImpl(Class<?> defaultImpl)
Method for specifying default implementation to use if type id
is either not available, or cannot be resolved.
|
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
|
T |
inclusion(JsonTypeInfo.As includeAs)
Method for specifying mechanism to use for including type metadata
in JSON.
|
T |
init(JsonTypeInfo.Id idType,
TypeIdResolver res)
Initialization method that is called right after constructing
the builder instance.
|
T |
typeIdVisibility(boolean isVisible)
Method for specifying whether type id should be visible to
JsonDeserializer s or not. |
T |
typeProperty(String propName)
Method for specifying name of property used for including type
information.
|
Class<?> getDefaultImpl()
TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes)
baseType
- Base type that constructed resolver will
handle; super type of all types it will be used for.TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes)
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.T init(JsonTypeInfo.Id idType, TypeIdResolver res)
idType
- Which type metadata is usedres
- (optional) Custom type id resolver used, if anyT inclusion(JsonTypeInfo.As includeAs)
JsonTypeInfo.As.PROPERTY
.includeAs
- Mechanism used for including type metadata in JSONT typeProperty(String propName)
JsonTypeInfo.As.PROPERTY
.
If not explicitly called, name of property to use is based on
defaults for JsonTypeInfo.Id
configured.
propName
- Name of JSON property to use for including
type informationT defaultImpl(Class<?> defaultImpl)
T typeIdVisibility(boolean isVisible)
JsonDeserializer
s or not.Copyright © 2021 JBoss by Red Hat. All rights reserved.