1 package com.fasterxml.jackson.databind.type;
2
3 import com.fasterxml.jackson.databind.JavaType;
4
5 /**
6  * Helper type used when introspecting bindings for already resolved types,
7  * needed for specialization.
8  *
9  * @since 2.8.11
10  */

11 public class PlaceholderForType extends TypeBase
12 {
13     private static final long serialVersionUID = 1L;
14
15     protected final int _ordinal;
16
17     /**
18      * Type assigned during wildcard resolution (which follows type
19      * structure resolution)
20      */

21     protected JavaType _actualType;
22     
23     public PlaceholderForType(int ordinal)
24     {
25         super(Object.class, TypeBindings.emptyBindings(),
26                 TypeFactory.unknownType(), null, 1, // super-classsuper-interfaces, hashCode
27                 nullnullfalse); // value/type handler, as-static
28         _ordinal = ordinal;
29     }
30
31     public JavaType actualType() { return _actualType; }
32     public void actualType(JavaType t) { _actualType = t; }
33
34     // Override to get better diagnostics
35     @Override
36     protected String buildCanonicalName() {
37         return toString();
38     }
39
40     @Override
41     public StringBuilder getGenericSignature(StringBuilder sb) {
42         return getErasedSignature(sb);
43     }
44
45     @Override
46     public StringBuilder getErasedSignature(StringBuilder sb) {
47         sb.append('$').append(_ordinal+1);
48         return sb;
49     }
50
51     @Override
52     public JavaType withTypeHandler(Object h) {
53         return _unsupported();
54     }
55
56     @Override
57     public JavaType withContentTypeHandler(Object h) {
58         return _unsupported();
59     }
60
61     @Override
62     public JavaType withValueHandler(Object h) {
63         return _unsupported();
64     }
65
66     @Override
67     public JavaType withContentValueHandler(Object h) {
68         return _unsupported();
69     }
70
71     @Override
72     public JavaType withContentType(JavaType contentType) {
73         return _unsupported();
74     }
75
76     @Override
77     public JavaType withStaticTyping() {
78         return _unsupported();
79     }
80
81     @Override
82     public JavaType refine(Class<?> rawType, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) {
83         return _unsupported();
84     }
85
86     @Override
87     @Deprecated // since 2.7
88     protected JavaType _narrow(Class<?> subclass) {
89         return _unsupported();
90     }
91
92     @Override
93     public boolean isContainerType() {
94         return false;
95     }
96
97     @Override
98     public String toString() {
99         return getErasedSignature(new StringBuilder()).toString();
100     }
101
102     @Override
103     public boolean equals(Object o) {
104         return (o == this);
105     }
106
107     private <T> T _unsupported() {
108         throw new UnsupportedOperationException("Operation should not be attempted on "+getClass().getName());
109     }
110 }
111