Class StdTypeResolverBuilder
- java.lang.Object
-
- com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder
-
- All Implemented Interfaces:
TypeResolverBuilder<StdTypeResolverBuilder>
- Direct Known Subclasses:
ObjectMapper.DefaultTypeResolverBuilder
public class StdTypeResolverBuilder extends Object implements TypeResolverBuilder<StdTypeResolverBuilder>
DefaultTypeResolverBuilderimplementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected TypeIdResolver_customIdResolverprotected Class<?>_defaultImplDefault class to use in case type information is not available or is broken.protected com.fasterxml.jackson.annotation.JsonTypeInfo.Id_idTypeprotected com.fasterxml.jackson.annotation.JsonTypeInfo.As_includeAsprotected boolean_typeIdVisibleWhether type id should be exposed to deserializers or notprotected String_typeProperty
-
Constructor Summary
Constructors Modifier Constructor Description StdTypeResolverBuilder()protectedStdTypeResolverBuilder(com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType, com.fasterxml.jackson.annotation.JsonTypeInfo.As idAs, String propName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeDeserializerbuildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes)Method for building type deserializer based on current configuration of this builder.TypeSerializerbuildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes)Method for building type serializer based on current configuration of this builder.StdTypeResolverBuilderdefaultImpl(Class<?> defaultImpl)Method for specifying default implementation to use if type id is either not available, or cannot be resolved.protected JavaTypedefineDefaultImpl(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 resolutionStringgetTypeProperty()protected TypeIdResolveridResolver(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.StdTypeResolverBuilderinclusion(com.fasterxml.jackson.annotation.JsonTypeInfo.As includeAs)Method for specifying mechanism to use for including type metadata in JSON.StdTypeResolverBuilderinit(com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType, TypeIdResolver idRes)Initialization method that is called right after constructing the builder instance.booleanisTypeIdVisible()static StdTypeResolverBuildernoTypeInfoBuilder()protected PolymorphicTypeValidatorreportInvalidBaseType(MapperConfig<?> config, JavaType baseType, PolymorphicTypeValidator ptv)PolymorphicTypeValidatorsubTypeValidator(MapperConfig<?> config)Overridable helper method for determining actual validator to use when constructing type serializers and type deserializers.StdTypeResolverBuildertypeIdVisibility(boolean isVisible)Method for specifying whether type id should be visible toJsonDeserializers or not.StdTypeResolverBuildertypeProperty(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 PolymorphicTypeValidatorverifyBaseTypeValidity(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.
-
-
-
Field Detail
-
_idType
protected com.fasterxml.jackson.annotation.JsonTypeInfo.Id _idType
-
_includeAs
protected com.fasterxml.jackson.annotation.JsonTypeInfo.As _includeAs
-
_typeProperty
protected String _typeProperty
-
_typeIdVisible
protected boolean _typeIdVisible
Whether type id should be exposed to deserializers or not
-
_defaultImpl
protected Class<?> _defaultImpl
Default class to use in case type information is not available or is broken.
-
_customIdResolver
protected TypeIdResolver _customIdResolver
-
-
Constructor Detail
-
StdTypeResolverBuilder
public StdTypeResolverBuilder()
-
StdTypeResolverBuilder
protected StdTypeResolverBuilder(com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType, com.fasterxml.jackson.annotation.JsonTypeInfo.As idAs, String propName)- Since:
- 2.9
-
-
Method Detail
-
noTypeInfoBuilder
public static StdTypeResolverBuilder noTypeInfoBuilder()
-
init
public StdTypeResolverBuilder init(com.fasterxml.jackson.annotation.JsonTypeInfo.Id idType, TypeIdResolver idRes)
Description copied from interface:TypeResolverBuilderInitialization method that is called right after constructing the builder instance.- Specified by:
initin interfaceTypeResolverBuilder<StdTypeResolverBuilder>- Parameters:
idType- Which type metadata is usedidRes- (optional) Custom type id resolver used, if any- Returns:
- Resulting builder instance (usually this builder, but not necessarily)
-
buildTypeSerializer
public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes)
Description copied from interface:TypeResolverBuilderMethod for building type serializer based on current configuration of this builder.- Specified by:
buildTypeSerializerin interfaceTypeResolverBuilder<StdTypeResolverBuilder>baseType- Base type that constructed resolver will handle; super type of all types it will be used for.
-
buildTypeDeserializer
public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes)
Description copied from interface:TypeResolverBuilderMethod for building type deserializer based on current configuration of this builder.- Specified by:
buildTypeDeserializerin interfaceTypeResolverBuilder<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.
-
defineDefaultImpl
protected JavaType defineDefaultImpl(DeserializationConfig config, JavaType baseType)
-
inclusion
public StdTypeResolverBuilder inclusion(com.fasterxml.jackson.annotation.JsonTypeInfo.As includeAs)
Description copied from interface:TypeResolverBuilderMethod for specifying mechanism to use for including type metadata in JSON. If not explicitly called, setting defaults toJsonTypeInfo.As.PROPERTY.- Specified by:
inclusionin interfaceTypeResolverBuilder<StdTypeResolverBuilder>- 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
public 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).- Specified by:
typePropertyin interfaceTypeResolverBuilder<StdTypeResolverBuilder>- Parameters:
typeIdPropName- 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
public StdTypeResolverBuilder defaultImpl(Class<?> defaultImpl)
Description copied from interface:TypeResolverBuilderMethod for specifying default implementation to use if type id is either not available, or cannot be resolved.- Specified by:
defaultImplin interfaceTypeResolverBuilder<StdTypeResolverBuilder>- Returns:
- Resulting builder instance (usually this builder, but may be a newly constructed instance for immutable builders}
-
typeIdVisibility
public StdTypeResolverBuilder typeIdVisibility(boolean isVisible)
Description copied from interface:TypeResolverBuilderMethod for specifying whether type id should be visible toJsonDeserializers or not.- Specified by:
typeIdVisibilityin interfaceTypeResolverBuilder<StdTypeResolverBuilder>- Returns:
- Resulting builder instance (usually this builder, but may be a newly constructed instance for immutable builders}
-
getDefaultImpl
public Class<?> getDefaultImpl()
Description copied from interface:TypeResolverBuilderAccessor for currently configured default type; implementation class that may be used in case no valid type information is available during type resolution- Specified by:
getDefaultImplin interfaceTypeResolverBuilder<StdTypeResolverBuilder>
-
getTypeProperty
public String getTypeProperty()
-
isTypeIdVisible
public boolean isTypeIdVisible()
-
idResolver
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.
-
subTypeValidator
public PolymorphicTypeValidator subTypeValidator(MapperConfig<?> config)
Overridable helper method for determining actual validator to use when constructing type serializers and type deserializers.Default implementation simply uses one configured and accessible using
MapperConfig.getPolymorphicTypeValidator().- Since:
- 2.10
-
verifyBaseTypeValidity
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. Currently limits are verified for class name - based methods only.- Since:
- 2.10
-
reportInvalidBaseType
protected PolymorphicTypeValidator reportInvalidBaseType(MapperConfig<?> config, JavaType baseType, PolymorphicTypeValidator ptv)
- Since:
- 2.10
-
-