• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.databind.introspect;
2 
3 import java.lang.reflect.Type;
4 
5 import com.fasterxml.jackson.databind.JavaType;
6 import com.fasterxml.jackson.databind.type.TypeBindings;
7 import com.fasterxml.jackson.databind.type.TypeFactory;
8 
9 /**
10  * Interface that defines API used by members (like {@link AnnotatedMethod})
11  * to dynamically resolve types they have.
12  *
13  * @since 2.7
14  */
15 public interface TypeResolutionContext {
resolveType(Type t)16     public JavaType resolveType(Type t);
17 
18     public static class Basic
19         implements TypeResolutionContext
20     {
21         private final TypeFactory _typeFactory;
22         private final TypeBindings _bindings;
23 
Basic(TypeFactory tf, TypeBindings b)24         public Basic(TypeFactory tf, TypeBindings b) {
25             _typeFactory = tf;
26             _bindings = b;
27         }
28 
29         @Override
resolveType(Type type)30         public JavaType resolveType(Type type) {
31             // 15-Jun-2020, tatu: As a consequence of [databind#2796], need to
32             //    AVOID passing bindings for raw, type-erased cases, as otherwise
33             //    we seem to get odd "generic Long" cases (for Mr Bean module at least)
34             if (type instanceof Class<?>) {
35                 return _typeFactory.constructType(type);
36             }
37             return _typeFactory.constructType(type, _bindings);
38         }
39 
40         /*// debugging
41         @Override
42         public String toString() {
43             return "[TRC.Basic, bindings: "+_bindings+"]";
44         }
45         */
46     }
47 }
48