public class StdTypeResolverBuilder extends Object implements TypeResolverBuilder<StdTypeResolverBuilder>
TypeResolverBuilder
implementation.Modifier and Type | Field and Description |
---|---|
protected TypeIdResolver |
_customIdResolver |
protected Class<?> |
_defaultImpl
Default class to use in case type information is not available
or is broken.
|
protected com.fasterxml.jackson.annotation.JsonTypeInfo.Id |
_idType |
protected com.fasterxml.jackson.annotation.JsonTypeInfo.As |
_includeAs |
protected Boolean |
_requireTypeIdForSubtypes
Boolean value configured through
JsonTypeInfo.requireTypeIdForSubtypes() . |
protected boolean |
_typeIdVisible
Whether type id should be exposed to deserializers or not
|
protected String |
_typeProperty |
Modifier | Constructor and Description |
---|---|
|
StdTypeResolverBuilder() |
protected |
StdTypeResolverBuilder(com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType,
com.fasterxml.jackson.annotation.JsonTypeInfo.As idAs,
String propName) |
|
StdTypeResolverBuilder(com.fasterxml.jackson.annotation.JsonTypeInfo.Value settings) |
protected |
StdTypeResolverBuilder(StdTypeResolverBuilder base,
Class<?> defaultImpl)
Copy-constructor
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
_hasTypeResolver(DeserializationConfig config,
JavaType baseType)
Checks whether the given class has annotations indicating some type resolver
is applied, for example
JsonTypeInfo . |
protected static String |
_propName(String propName,
com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType) |
protected boolean |
_strictTypeIdHandling(DeserializationConfig config,
JavaType baseType)
Determines whether strict type ID handling should be used for this type or not.
|
protected boolean |
allowPrimitiveTypes(MapperConfig<?> config,
JavaType baseType)
Overridable helper method that is called to determine whether type serializers
and type deserializers may be created even if base type is Java
primitive
type. |
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.
|
StdTypeResolverBuilder |
defaultImpl(Class<?> defaultImpl)
Method for specifying default implementation to use if type id
is either not available, or cannot be resolved.
|
protected JavaType |
defineDefaultImpl(DeserializationConfig config,
JavaType baseType) |
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
|
String |
getTypeProperty() |
protected TypeIdResolver |
idResolver(MapperConfig<?> config,
JavaType baseType,
PolymorphicTypeValidator subtypeValidator,
Collection<NamedType> subtypes,
boolean forSer,
boolean forDeser)
Helper method that will either return configured custom
type id resolver, or construct a standard resolver
given configuration.
|
StdTypeResolverBuilder |
inclusion(com.fasterxml.jackson.annotation.JsonTypeInfo.As includeAs)
Method for specifying mechanism to use for including type metadata
in JSON.
|
StdTypeResolverBuilder |
init(com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType,
TypeIdResolver idRes)
Initialization method that is called right after constructing
the builder instance.
|
StdTypeResolverBuilder |
init(com.fasterxml.jackson.annotation.JsonTypeInfo.Value settings,
TypeIdResolver idRes)
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)
|
boolean |
isTypeIdVisible() |
static StdTypeResolverBuilder |
noTypeInfoBuilder() |
protected PolymorphicTypeValidator |
reportInvalidBaseType(MapperConfig<?> config,
JavaType baseType,
PolymorphicTypeValidator ptv) |
PolymorphicTypeValidator |
subTypeValidator(MapperConfig<?> config)
Overridable helper method for determining actual validator to use when constructing
type serializers and type deserializers.
|
StdTypeResolverBuilder |
typeIdVisibility(boolean isVisible)
Method for specifying whether type id should be visible to
JsonDeserializer s or not. |
StdTypeResolverBuilder |
typeProperty(String typeIdPropName)
Method for constructing an instance with specified type property name
(property name to use for type id when using "as-property" inclusion).
|
protected PolymorphicTypeValidator |
verifyBaseTypeValidity(MapperConfig<?> config,
JavaType baseType)
Helper method called to check that base type is valid regarding possible constraints
on basetype/subtype combinations allowed for polymorphic type handling.
|
StdTypeResolverBuilder |
withDefaultImpl(Class<?> defaultImpl)
"Mutant factory" method for creating a new instance with different default
implementation.
|
StdTypeResolverBuilder |
withSettings(com.fasterxml.jackson.annotation.JsonTypeInfo.Value settings)
Method for overriding type information.
|
protected com.fasterxml.jackson.annotation.JsonTypeInfo.Id _idType
protected com.fasterxml.jackson.annotation.JsonTypeInfo.As _includeAs
protected String _typeProperty
protected boolean _typeIdVisible
protected Boolean _requireTypeIdForSubtypes
JsonTypeInfo.requireTypeIdForSubtypes()
.
If this value is not null
, this value should override the global configuration of
MapperFeature.REQUIRE_TYPE_ID_FOR_SUBTYPES
.protected Class<?> _defaultImpl
protected TypeIdResolver _customIdResolver
public StdTypeResolverBuilder()
protected StdTypeResolverBuilder(com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType, com.fasterxml.jackson.annotation.JsonTypeInfo.As idAs, String propName)
protected StdTypeResolverBuilder(StdTypeResolverBuilder base, Class<?> defaultImpl)
public StdTypeResolverBuilder(com.fasterxml.jackson.annotation.JsonTypeInfo.Value settings)
protected static String _propName(String propName, com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType)
public static StdTypeResolverBuilder noTypeInfoBuilder()
public StdTypeResolverBuilder init(com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType, TypeIdResolver idRes)
TypeResolverBuilder
init
in interface TypeResolverBuilder<StdTypeResolverBuilder>
idType
- Which type metadata is usedidRes
- (optional) Custom type id resolver used, if anypublic StdTypeResolverBuilder init(com.fasterxml.jackson.annotation.JsonTypeInfo.Value settings, TypeIdResolver idRes)
TypeResolverBuilder
NOTE: This method is abstract in Jackson 3.0, at the moment of writing.
init
in interface TypeResolverBuilder<StdTypeResolverBuilder>
settings
- Configuration settings to apply.public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes)
TypeResolverBuilder
buildTypeSerializer
in interface TypeResolverBuilder<StdTypeResolverBuilder>
baseType
- Base type that constructed resolver will
handle; super type of all types it will be used for.public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes)
TypeResolverBuilder
buildTypeDeserializer
in interface TypeResolverBuilder<StdTypeResolverBuilder>
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.protected JavaType defineDefaultImpl(DeserializationConfig config, JavaType baseType)
public StdTypeResolverBuilder inclusion(com.fasterxml.jackson.annotation.JsonTypeInfo.As includeAs)
TypeResolverBuilder
JsonTypeInfo.As.PROPERTY
.inclusion
in interface TypeResolverBuilder<StdTypeResolverBuilder>
includeAs
- Mechanism used for including type metadata in JSONpublic StdTypeResolverBuilder typeProperty(String typeIdPropName)
typeProperty
in interface TypeResolverBuilder<StdTypeResolverBuilder>
typeIdPropName
- Name of JSON property to use for including
type informationpublic StdTypeResolverBuilder defaultImpl(Class<?> defaultImpl)
TypeResolverBuilder
defaultImpl
in interface TypeResolverBuilder<StdTypeResolverBuilder>
public StdTypeResolverBuilder typeIdVisibility(boolean isVisible)
TypeResolverBuilder
JsonDeserializer
s or not.typeIdVisibility
in interface TypeResolverBuilder<StdTypeResolverBuilder>
public StdTypeResolverBuilder withDefaultImpl(Class<?> defaultImpl)
TypeResolverBuilder
withDefaultImpl
in interface TypeResolverBuilder<StdTypeResolverBuilder>
public StdTypeResolverBuilder withSettings(com.fasterxml.jackson.annotation.JsonTypeInfo.Value settings)
TypeResolverBuilder
withSettings
in interface TypeResolverBuilder<StdTypeResolverBuilder>
public Class<?> getDefaultImpl()
TypeResolverBuilder
getDefaultImpl
in interface TypeResolverBuilder<StdTypeResolverBuilder>
public String getTypeProperty()
public boolean isTypeIdVisible()
protected TypeIdResolver idResolver(MapperConfig<?> config, JavaType baseType, PolymorphicTypeValidator subtypeValidator, Collection<NamedType> subtypes, boolean forSer, boolean forDeser)
public PolymorphicTypeValidator subTypeValidator(MapperConfig<?> config)
Default implementation simply uses one configured and accessible using
MapperConfig.getPolymorphicTypeValidator()
.
protected PolymorphicTypeValidator verifyBaseTypeValidity(MapperConfig<?> config, JavaType baseType)
protected PolymorphicTypeValidator reportInvalidBaseType(MapperConfig<?> config, JavaType baseType, PolymorphicTypeValidator ptv)
protected boolean allowPrimitiveTypes(MapperConfig<?> config, JavaType baseType)
primitive
type.
Default implementation simply returns false
(since primitive types can not
be sub-classed, are never polymorphic) but custom implementations
may change the logic for some special cases.config
- Currently active configurationbaseType
- Primitive base type for property being handledprimitive
type; false if notprotected boolean _strictTypeIdHandling(DeserializationConfig config, JavaType baseType)
JsonTypeInfo.requireTypeIdForSubtypes()
unless its value is OptBoolean.DEFAULT
.
In case the value of JsonTypeInfo.requireTypeIdForSubtypes()
is OptBoolean.DEFAULT
,
this will be enabled when either the type has type resolver annotations or if
MapperFeature.REQUIRE_TYPE_ID_FOR_SUBTYPES
is enabled.config
- the deserialization configuration to usebaseType
- the base type to check for type resolver annotationstrue
if the class has type resolver annotations, or the strict
handling feature is enabled, false
otherwise.protected boolean _hasTypeResolver(DeserializationConfig config, JavaType baseType)
JsonTypeInfo
.
Only initializes _hasTypeResolver(com.fasterxml.jackson.databind.DeserializationConfig, com.fasterxml.jackson.databind.JavaType)
once if its value is null.config
- the deserialization configuration to usebaseType
- the base type to check for type resolver annotationsai.findPolymorphicTypeInfo(config, ac)
since 2.16.Copyright © 2008–2023 FasterXML. All rights reserved.