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