public final class ApprovedBaseTypeValidator extends PolymorphicTypeValidator.Base
PolymorphicTypeValidator used when the configured validator has approved
all subtypes of a polymorphic base type (by returning
Validity#ALLOWED from validateBaseType(com.fasterxml.jackson.databind.cfg.MapperConfig<?>, com.fasterxml.jackson.databind.JavaType)).
Like LaissezFaireSubTypeValidator it allows all subtypes of that base type,
but retains the configured validator so that classes named as type parameters
of a generic type id (like "java.util.HashMap<a.b.Gadget,java.lang.String>")
can still be validated: approval of the base type does not extend to them.PolymorphicTypeValidator.Base, PolymorphicTypeValidator.Validity| Constructor and Description |
|---|
ApprovedBaseTypeValidator(PolymorphicTypeValidator typeParameterValidator) |
| Modifier and Type | Method and Description |
|---|---|
PolymorphicTypeValidator |
getTypeParameterValidator()
Accessor for the configured validator, to use for validating type parameters
of generic type ids.
|
PolymorphicTypeValidator.Validity |
validateBaseType(MapperConfig<?> ctxt,
JavaType baseType)
Method called when a property with polymorphic value is encountered, and a
TypeResolverBuilder is needed. |
PolymorphicTypeValidator.Validity |
validateSubClassName(MapperConfig<?> ctxt,
JavaType baseType,
String subClassName)
|
PolymorphicTypeValidator.Validity |
validateSubType(MapperConfig<?> ctxt,
JavaType baseType,
JavaType subType)
Method called after class name has been resolved to actual type, in cases where previous
call to
PolymorphicTypeValidator.validateSubClassName(com.fasterxml.jackson.databind.cfg.MapperConfig<?>, com.fasterxml.jackson.databind.JavaType, java.lang.String) returned PolymorphicTypeValidator.Validity.INDETERMINATE. |
isArrayTypeAllowedExplicitlypublic ApprovedBaseTypeValidator(PolymorphicTypeValidator typeParameterValidator)
public PolymorphicTypeValidator getTypeParameterValidator()
public PolymorphicTypeValidator.Validity validateBaseType(MapperConfig<?> ctxt, JavaType baseType)
PolymorphicTypeValidatorTypeResolverBuilder is needed. Intent is to allow early determination
of cases where subtyping is completely denied (for example for security reasons),
or, conversely, allowed for allow subtypes (when base type guarantees that all subtypes
are known to be safe). Check can be thought of as both optimization (for latter case)
and eager-fail (for former case) to give better feedback.validateBaseType in class PolymorphicTypeValidator.Basectxt - Configuration for resolution: typically will be DeserializationConfigbaseType - Nominal base type used for polymorphic handling: subtypes MUST be instances
of this type and assignment compatibility is verified by Jackson corePolymorphicTypeValidator.Validity.ALLOWED returned, all subtypes will automatically be accepted without
further checks; is PolymorphicTypeValidator.Validity.DENIED returned no subtyping allowed at all
(caller will usually throw an exception); otherwise (return PolymorphicTypeValidator.Validity.INDETERMINATE)
per sub-type validation calls are made for each new subclass encountered.public PolymorphicTypeValidator.Validity validateSubClassName(MapperConfig<?> ctxt, JavaType baseType, String subClassName)
PolymorphicTypeValidatorClass or JavaType.
Validator may be able to
determine validity of eventual type (and return PolymorphicTypeValidator.Validity.ALLOWED or
PolymorphicTypeValidator.Validity.DENIED) or, if not able to, can defer validation to actual
resolved type by returning PolymorphicTypeValidator.Validity.INDETERMINATE.
Validator may also choose to indicate denial by throwing a JsonMappingException
(such as InvalidTypeIdException)
validateSubClassName in class PolymorphicTypeValidator.Basectxt - Configuration for resolution: typically will be DeserializationConfigbaseType - Nominal base type used for polymorphic handling: subtypes MUST be instances
of this type and assignment compatibility is verified by Jackson coresubClassName - Name of class that will be resolved to Class if
(and only if) validity check is not denied.nullpublic PolymorphicTypeValidator.Validity validateSubType(MapperConfig<?> ctxt, JavaType baseType, JavaType subType)
PolymorphicTypeValidatorPolymorphicTypeValidator.validateSubClassName(com.fasterxml.jackson.databind.cfg.MapperConfig<?>, com.fasterxml.jackson.databind.JavaType, java.lang.String) returned PolymorphicTypeValidator.Validity.INDETERMINATE.
Validator should be able to determine validity and return appropriate PolymorphicTypeValidator.Validity
value, although it may also
Validator may also choose to indicate denial by throwing a JsonMappingException
(such as InvalidTypeIdException)
validateSubType in class PolymorphicTypeValidator.Basectxt - Configuration for resolution: typically will be DeserializationConfigbaseType - Nominal base type used for polymorphic handling: subtypes MUST be instances
of this type and assignment compatibility has been verified by Jackson coresubType - Resolved subtype to validatenullCopyright © 2008–2026 FasterXML. All rights reserved.