|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.fasterxml.jackson.databind.AbstractTypeResolver com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver
public class SimpleAbstractTypeResolver
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
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 | |
---|---|
protected HashMap<ClassKey,Class<?>> |
_mappings
Mappings from super types to subtypes |
Constructor Summary | |
---|---|
SimpleAbstractTypeResolver()
|
Method Summary | ||
---|---|---|
|
addMapping(Class<T> superType,
Class<? extends T> subType)
Method for adding a mapping from super type to specific subtype. |
|
JavaType |
findTypeMapping(DeserializationConfig config,
JavaType type)
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. |
|
JavaType |
resolveAbstractType(DeserializationConfig config,
JavaType type)
Method called to try to resolve an abstract type into concrete type (usually for purposes of deserializing), when no concrete implementation was found. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final HashMap<ClassKey,Class<?>> _mappings
Constructor Detail |
---|
public SimpleAbstractTypeResolver()
Method Detail |
---|
public <T> SimpleAbstractTypeResolver addMapping(Class<T> superType, Class<? extends T> subType)
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).
superType
- Abstract type to resolvesubType
- Sub-class of superType, to map superTo to
public JavaType findTypeMapping(DeserializationConfig config, JavaType type)
AbstractTypeResolver
List
s).
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.
findTypeMapping
in class AbstractTypeResolver
config
- Configuration in use; should always be of type
DeserializationConfig
public JavaType resolveAbstractType(DeserializationConfig config, JavaType type)
AbstractTypeResolver
resolveAbstractType
in class AbstractTypeResolver
config
- Configuration in use; should always be of type
DeserializationConfig
type
- Type for which materialization maybe needed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |