Interface TypeResolverBuilder<T extends TypeResolverBuilder<T>>
- All Known Implementing Classes:
ObjectMapper.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(edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.annotation.JsonTypeInfo.Id, edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.jsontype.TypeIdResolver)
method, and then
configured using 'set' methods like inclusion(edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.annotation.JsonTypeInfo.As)
.
Finally, after calling all configuration methods,
buildTypeSerializer(edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.SerializationConfig, edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.JavaType, java.util.Collection<edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.jsontype.NamedType>)
or buildTypeDeserializer(edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.DeserializationConfig, edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.JavaType, java.util.Collection<edu.internet2.middleware.grouperClientExt.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:
- To create builders to use with explicit type information
inclusion (usually via
@JsonTypeInfo
annotation) - 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
(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes) Method for building type deserializer based on current configuration of this builder.buildTypeSerializer
(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes) Method for building type serializer based on current configuration of this builder.defaultImpl
(Class<?> defaultImpl) Method for specifying default implementation to use if type id is either not available, or cannot be resolved.Class<?>
Accessor for currently configured default type; implementation class that may be used in case no valid type information is available during type resolutioninclusion
(JsonTypeInfo.As includeAs) Method for specifying mechanism to use for including type metadata in JSON.init
(JsonTypeInfo.Id idType, TypeIdResolver res) Initialization method that is called right after constructing the builder instance.typeIdVisibility
(boolean isVisible) Method for specifying whether type id should be visible toJsonDeserializer
s or not.typeProperty
(String propName) Method for specifying name of property used for including type information.default T
withDefaultImpl
(Class<?> defaultImpl) "Mutant factory" method for creating a new instance with different default implementation.
-
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(SerializationConfig config, 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(DeserializationConfig config, 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.- Parameters:
idType
- Which type metadata is usedres
- (optional) Custom type id resolver used, if any- Returns:
- Resulting builder instance (usually this builder, but not necessarily)
-
inclusion
Method for specifying mechanism to use for including type metadata in JSON. If not explicitly called, setting defaults toJsonTypeInfo.As.PROPERTY
.- Parameters:
includeAs
- Mechanism used for including type metadata in JSON- Returns:
- Resulting builder instance (usually this builder, but may be a newly constructed instance for immutable builders}
-
typeProperty
Method for specifying name of property used for including type information. Not used for all inclusion mechanisms; usually only used withJsonTypeInfo.As.PROPERTY
.If not explicitly called, name of property to use is based on defaults for
JsonTypeInfo.Id
configured.- Parameters:
propName
- Name of JSON property to use for including type information- Returns:
- Resulting builder instance (usually this builder, but may be a newly constructed instance for immutable builders}
-
defaultImpl
Method for specifying default implementation to use if type id is either not available, or cannot be resolved.- Returns:
- Resulting builder instance (usually this builder, but may be a newly constructed instance for immutable builders}
-
typeIdVisibility
Method for specifying whether type id should be visible toJsonDeserializer
s or not.- Returns:
- Resulting builder instance (usually this builder, but may be a newly constructed instance for immutable builders}
- Since:
- 2.0
-
withDefaultImpl
"Mutant factory" method for creating a new instance with different default implementation.- Returns:
- Either this instance (if nothing changed) or a new instance with different default implementation
- Since:
- 2.13
-