Module tools.jackson.databind
Class DefaultTypeResolverBuilder
java.lang.Object
tools.jackson.databind.jsontype.impl.StdTypeResolverBuilder
tools.jackson.databind.jsontype.impl.DefaultTypeResolverBuilder
- All Implemented Interfaces:
Serializable,TypeResolverBuilder<StdTypeResolverBuilder>
Customized
TypeResolverBuilder that provides type resolver builders
used with so-called "default typing"
(see MapperBuilder.activateDefaultTyping(PolymorphicTypeValidator)
for details).
Type resolver construction is based on configuration: implementation takes care of only providing builders in cases where type information should be applied. This is important since build calls may be sent for any and all types, and type information should NOT be applied to all of them.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DefaultTypingDefinition of what types is this default typer valid for.protected final PolymorphicTypeValidatorValidator to use for checking that only valid subtypes are accepted from incoming content.Fields inherited from class tools.jackson.databind.jsontype.impl.StdTypeResolverBuilder
_customIdResolver, _defaultImpl, _idType, _includeAs, _requireTypeIdForSubtypes, _typeIdVisible, _typeProperty -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefaultTypeResolverBuilder(DefaultTypeResolverBuilder base, Class<?> defaultImpl) DefaultTypeResolverBuilder(PolymorphicTypeValidator subtypeValidator, DefaultTyping t, JsonTypeInfo.As includeAs) DefaultTypeResolverBuilder(PolymorphicTypeValidator subtypeValidator, DefaultTyping t, JsonTypeInfo.As includeAs, JsonTypeInfo.Id idType, String propertyName) DefaultTypeResolverBuilder(PolymorphicTypeValidator subtypeValidator, DefaultTyping t, String propertyName) -
Method Summary
Modifier and TypeMethodDescriptionprotected JavaTypeprotected JavaTypebuildTypeDeserializer(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.Overridable helper method for determining actual validator to use when constructing type serializers and type deserializers.typeIdVisibility(boolean isVisible) booleanMethod called to check if the default type handler should be used for given type.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.Methods inherited from class tools.jackson.databind.jsontype.impl.StdTypeResolverBuilder
_hasTypeResolver, _propName, _strictTypeIdHandling, allowPrimitiveTypes, defineDefaultImpl, getDefaultImpl, getTypeProperty, idResolver, init, isTypeIdVisible, noTypeInfoBuilder, reportInvalidBaseType, verifyBaseTypeValidity, withSettings
-
Field Details
-
_subtypeValidator
Validator to use for checking that only valid subtypes are accepted from incoming content. -
_appliesFor
Definition of what types is this default typer valid for.
-
-
Constructor Details
-
DefaultTypeResolverBuilder
public DefaultTypeResolverBuilder(PolymorphicTypeValidator subtypeValidator, DefaultTyping t, JsonTypeInfo.As includeAs) -
DefaultTypeResolverBuilder
public DefaultTypeResolverBuilder(PolymorphicTypeValidator subtypeValidator, DefaultTyping t, String propertyName) -
DefaultTypeResolverBuilder
public DefaultTypeResolverBuilder(PolymorphicTypeValidator subtypeValidator, DefaultTyping t, JsonTypeInfo.As includeAs, JsonTypeInfo.Id idType, String propertyName) -
DefaultTypeResolverBuilder
-
-
Method Details
-
withDefaultImpl
Description copied from interface:TypeResolverBuilder"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.- Specified by:
withDefaultImplin interfaceTypeResolverBuilder<StdTypeResolverBuilder>- Overrides:
withDefaultImplin classStdTypeResolverBuilder- Returns:
- Either this instance (if nothing changed) or a new instance with different default implementation
-
subTypeValidator
Description copied from class:StdTypeResolverBuilderOverridable 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().- Overrides:
subTypeValidatorin classStdTypeResolverBuilder
-
buildTypeDeserializer
public TypeDeserializer buildTypeDeserializer(DeserializationContext ctxt, 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>- Overrides:
buildTypeDeserializerin classStdTypeResolverBuilderbaseType- Base type that constructed resolver will handle; super type of all types it will be used for.subtypes- Known subtypes of the base type.
-
buildTypeSerializer
public TypeSerializer buildTypeSerializer(SerializationContext ctxt, 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>- Overrides:
buildTypeSerializerin classStdTypeResolverBuilderbaseType- Base type that constructed resolver will handle; super type of all types it will be used for.
-
typeIdVisibility
-
useForType
Method called to check if the default type handler should be used for given type. Note: "natural types" (String, Boolean, Integer, Double) will never use typing; that is both due to them being concrete and final, and since actual serializers and deserializers will also ignore any attempts to enforce typing. -
_unwrapArrayType
-
_unwrapReferenceType
-