Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.module

public Class SimpleAbstractTypeResolver

extends AbstractTypeResolver
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.lang.reflect.Modifier, java.util.*, com.fasterxml.jackson.databind.AbstractTypeResolver, .BeanDescription, .DeserializationConfig, .JavaType, com.fasterxml.jackson.databind.type.ClassKey

Simple AbstractTypeResolver implementation, which is based on static mapping from abstract super types into sub types (concrete or abstract), but retaining generic parameterization. Can be used for things like specifying which implementation of java.util.Collection to use:
  SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
  // To make all properties declared as Collection, List, to LinkedList
  resolver.addMapping(Collection.class, LinkedList.class);
  resolver.addMapping(List.class, LinkedList.class);
Can also be used as an alternative to per-class annotations when defining concrete implementations; however, only works with abstract types (since this is only called for abstract types)

Field Summary

Modifier and TypeField and Description
protected final HashMap<ClassKey, Class<?>>
_mappings

Mappings from super types to subtypes

private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public <T> SimpleAbstractTypeResolver

Returns:

This resolver, to allow chaining of initializations
addMapping
(Class<T>
Abstract type to resolve
superType
,
Class<? extends T>
Sub-class of superType, to map superTo to
subType
)

Method for adding a mapping from super type to specific subtype.

public JavaType
findTypeMapping(DeserializationConfig
Configuration in use
config
,
JavaType
Type to find mapping for
type
)

Overrides com.fasterxml.jackson.databind.AbstractTypeResolver.findTypeMapping.

Try to locate a subtype for given abstract type, to either resolve to a concrete type, or at least to a more-specific (and hopefully supported) abstract type, one which may have registered deserializers.
public JavaType
public JavaType
resolveAbstractType(DeserializationConfig
Configuration in use
config
,
BeanDescription
Description of the POJO type to resolve
typeDesc
)

Overrides com.fasterxml.jackson.databind.AbstractTypeResolver.resolveAbstractType.

Method called to try to resolve an abstract type into concrete type (usually for purposes of deserializing), when no concrete implementation was found.

Field Detail

_mappingsback to summary
protected final HashMap<ClassKey, Class<?>> _mappings

Mappings from super types to subtypes

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

SimpleAbstractTypeResolverback to summary
public SimpleAbstractTypeResolver()

Method Detail

addMappingback to summary
public <T> SimpleAbstractTypeResolver addMapping(Class<T> superType, Class<? extends T> subType)

Method for adding a mapping from super type to specific subtype. Arguments will be checked by method, to ensure that superType is abstract (since resolver is never called for concrete classes); as well as to ensure that there is supertype/subtype relationship (to ensure there won't be cycles during resolution).

Parameters
superType:Class<T>

Abstract type to resolve

subType:Class<? extends T>

Sub-class of superType, to map superTo to

Returns:SimpleAbstractTypeResolver

This resolver, to allow chaining of initializations

findTypeMappingback to summary
public JavaType findTypeMapping(DeserializationConfig config, JavaType type)

Overrides com.fasterxml.jackson.databind.AbstractTypeResolver.findTypeMapping.

Doc from com.fasterxml.jackson.databind.AbstractTypeResolver.findTypeMapping.

Try to locate a subtype for given abstract type, to either resolve to a concrete type, or at least to a more-specific (and hopefully supported) abstract type, one which may have registered deserializers. Method is called before trying to locate registered deserializers (as well as standard abstract type defaulting that core Jackson does), so it is typically implemented to add custom mappings of common abstract types (like specify which concrete implementation to use for binding java.util.Lists).

Note that this method does not necessarily have to do full resolution of bindings; that is, it is legal to return type that could be further resolved: caller is expected to keep calling this method on registered resolvers, until a concrete type is located.

Parameters
config:DeserializationConfig

Configuration in use

type:JavaType

Type to find mapping for

Returns:JavaType

Type to map given input type (if mapping found) or null (if not).

Annotations
@Override
resolveAbstractTypeback to summary
public JavaType resolveAbstractType(DeserializationConfig config, JavaType type)

Overrides com.fasterxml.jackson.databind.AbstractTypeResolver.resolveAbstractType.

Doc from com.fasterxml.jackson.databind.AbstractTypeResolver.resolveAbstractType.

Deprecated

Older variant of resolveAbstractType(DeserializationConfig, BeanDescription); obsoleted in 2.7

Parameters
config:DeserializationConfig

Configuration in use

type:JavaType

Type to resolve

Returns:JavaType

Resolved concrete type

Annotations
@Override
@Deprecated
resolveAbstractTypeback to summary
public JavaType resolveAbstractType(DeserializationConfig config, BeanDescription typeDesc)

Overrides com.fasterxml.jackson.databind.AbstractTypeResolver.resolveAbstractType.

Doc from com.fasterxml.jackson.databind.AbstractTypeResolver.resolveAbstractType.

Method called to try to resolve an abstract type into concrete type (usually for purposes of deserializing), when no concrete implementation was found. It will be called after checking all other possibilities, including defaulting.

Parameters
config:DeserializationConfig

Configuration in use

typeDesc:BeanDescription

Description of the POJO type to resolve

Returns:JavaType

Resolved concrete type (which should retain generic type parameters of input type, if any), if resolution succeeds; null if resolver does not know how to resolve given type

Annotations
@Override