1 package com.fasterxml.jackson.databind;
2 
3 /**
4  * Defines interface for resolvers that can resolve abstract types into concrete
5  * ones; either by using static mappings, or possibly by materializing
6  * implementations dynamically.
7  */
8 public abstract class AbstractTypeResolver
9 {
10     /**
11      * Try to locate a subtype for given abstract type, to either resolve
12      * to a concrete type, or at least to a more-specific (and hopefully supported)
13      * abstract type, one which may have registered deserializers.
14      * Method is called before trying to locate registered deserializers
15      * (as well as standard abstract type defaulting that core Jackson does),
16      * so it is typically implemented to add custom mappings of common abstract
17      * types (like specify which concrete implementation to use for binding
18      * {@link java.util.List}s).
19      *<p>
20      * Note that this method does not necessarily have to do full resolution
21      * of bindings; that is, it is legal to return type that could be further
22      * resolved: caller is expected to keep calling this method on registered
23      * resolvers, until a concrete type is located.
24      *
25      * @param config Configuration in use
26      * @param type Type to find mapping for
27      *
28      * @return Type to map given input type (if mapping found) or {@code null} (if not).
29      */
findTypeMapping(DeserializationConfig config, JavaType type)30     public JavaType findTypeMapping(DeserializationConfig config, JavaType type) {
31         return null;
32     }
33 
34     /**
35      * Older variant of {@link #resolveAbstractType(DeserializationConfig, BeanDescription)};
36      * obsoleted in 2.7
37      *
38      * @deprecated since 2.8 (may be removed from 2.9 or later)
39      *
40      * @param config Configuration in use
41      * @param type Type to resolve
42      *
43      * @return Resolved concrete type
44      */
45     @Deprecated
resolveAbstractType(DeserializationConfig config, JavaType type)46     public JavaType resolveAbstractType(DeserializationConfig config,
47             JavaType type) {
48         return null;
49     }
50 
51     /**
52      * Method called to try to resolve an abstract type into
53      * concrete type (usually for purposes of deserializing),
54      * when no concrete implementation was found.
55      * It will be called after checking all other possibilities,
56      * including defaulting.
57      *
58      * @param config Configuration in use
59      * @param typeDesc Description of the POJO type to resolve
60      *
61      * @return Resolved concrete type (which should retain generic
62      *    type parameters of input type, if any), if resolution succeeds;
63      *    null if resolver does not know how to resolve given type
64      *
65      * @since 2.7
66      */
resolveAbstractType(DeserializationConfig config, BeanDescription typeDesc)67     public JavaType resolveAbstractType(DeserializationConfig config,
68             BeanDescription typeDesc) {
69         return null;
70     }
71 }
72