@Override @Deprecated // since 2.7 public TypeBindings bindingsForBeanType() { return _type.getBindings(); }
@Override @Deprecated // since 2.8 public JavaType resolveType(java.lang.reflect.Type jdkType) { if (jdkType == null) { return null; } return _config.getTypeFactory().constructType(jdkType, _type.getBindings()); }
@Override public JavaType[] findTypeParameters(Class<?> expType) { JavaType match = findSuperType(expType); if (match == null) { return NO_TYPES; } return match.getBindings().typeParameterArray(); }
/** * @deprecated Since 2.7 (accidentally removed in 2.7.0; added back in 2.7.1) */ @Deprecated public JavaType constructType(Type type, JavaType contextType) { TypeBindings bindings; if (contextType == null) { bindings = EMPTY_BINDINGS; } else { bindings = contextType.getBindings(); // 16-Nov-2016, tatu: Unfortunately as per [databind#1456] this can't // be made to work for some cases used to work (even if accidentally); // however, we can try a simple heuristic to increase chances of // compatibility from 2.6 code if (type.getClass() != Class.class) { // Ok: so, ideally we would test super-interfaces if necessary; // but let's assume most if not all cases are for classes. while (bindings.isEmpty()) { contextType = contextType.getSuperClass(); if (contextType == null) { break; } bindings = contextType.getBindings(); } } } return _fromAny(null, type, bindings); }
/** * Method that is to figure out actual type parameters that given * class binds to generic types defined by given (generic) * interface or class. * This could mean, for example, trying to figure out * key and value types for Map implementations. * * @param type Sub-type (leaf type) that implements <code>expType</code> */ public JavaType[] findTypeParameters(JavaType type, Class<?> expType) { JavaType match = type.findSuperType(expType); if (match == null) { return NO_TYPES; } return match.getBindings().typeParameterArray(); }
private boolean _verifyAndResolvePlaceholders(JavaType exp, JavaType act) { // See if we have an actual type placeholder to resolve; if yes, replace if (act instanceof PlaceholderForType) { ((PlaceholderForType) act).actualType(exp); return true; } // if not, try to verify compatibility. But note that we can not // use simple equality as we need to resolve recursively if (exp.getRawClass() != act.getRawClass()) { return false; } // But we can check type parameters "blindly" List<JavaType> expectedTypes = exp.getBindings().getTypeParameters(); List<JavaType> actualTypes = act.getBindings().getTypeParameters(); for (int i = 0, len = expectedTypes.size(); i < len; ++i) { JavaType exp2 = expectedTypes.get(i); JavaType act2 = actualTypes.get(i); if (!_verifyAndResolvePlaceholders(exp2, act2)) { return false; } } return true; }
AnnotatedClassResolver(MapperConfig<?> config, JavaType type, MixInResolver r) { _config = config; _type = type; _class = type.getRawClass(); _mixInResolver = r; _bindings = type.getBindings(); _intr = config.isAnnotationProcessingEnabled() ? config.getAnnotationIntrospector() : null; _primaryMixin = _config.findMixInClassFor(_class); }
TypeBindings b = resultType.getBindings(); if (b == null) { b = EMPTY_BINDINGS;
Class<?> mixin = (_mixInResolver == null) ? null : _mixInResolver.findMixInClassFor(type.getRawClass()); _addMemberMethods( new TypeResolutionContext.Basic(typeFactory, type.getBindings()), type.getRawClass(), methods, mixin);
private String _resolveTypePlaceholders(JavaType sourceType, JavaType actualType) throws IllegalArgumentException List<JavaType> expectedTypes = sourceType.getBindings().getTypeParameters(); List<JavaType> actualTypes = actualType.getBindings().getTypeParameters(); for (int i = 0, len = expectedTypes.size(); i < len; ++i) { JavaType exp = expectedTypes.get(i);
fields = _findFields(new TypeResolutionContext.Basic(_typeFactory, parent.getBindings()), parent, fields); for (Field f : ClassUtil.getDeclaredFields(cls)) {
if (baseType.getBindings().isEmpty()) { newType = _fromClass(null, subclass, EMPTY_BINDINGS); break;
@Override @Deprecated // since 2.7 public TypeBindings bindingsForBeanType() { return _type.getBindings(); }
protected TypeResolutionContext buildTypeContext(JavaType ctxtType) { return new TypeResolutionContext.Basic(_typeFactory, ctxtType.getBindings()); }
@Override @Deprecated // since 2.8 public JavaType resolveType(java.lang.reflect.Type jdkType) { if (jdkType == null) { return null; } return _config.getTypeFactory().constructType(jdkType, _type.getBindings()); }
private static List<JavaType> getGenericTypes(JavaType type) { if (type.getBindings() != null) { TypeBindings bindings = type.getBindings(); if (bindings.getTypeParameters() != null) { return bindings.getTypeParameters(); } } return Collections.emptyList(); }
protected TypeResolutionContext buildTypeContext(JavaType ctxtType) { return new TypeResolutionContext.Basic(_typeFactory, ctxtType.getBindings()); } }
private JavaType resolve(final JavaType type) { Assert.notNull(type, "type can't be null"); JavaType tmp = type; while(Keeper.class.equals(tmp.getRawClass())) { TypeBindings bindings = tmp.getBindings(); Assert.isTrue(bindings.size() == 1, "Bindings must have one parameter type: " + type); tmp = bindings.getBoundType(0); } return tmp; }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) { Class<?> resourceContentType = ctxt.getContextualType().getBindings().getTypeParameters().get(0).getRawClass(); return new ResourceDeserializer(resourceContentType, typeResolver, configuration); }
AnnotatedClassResolver(MapperConfig<?> config, JavaType type, MixInResolver r) { _config = config; _type = type; _class = type.getRawClass(); _mixInResolver = r; _bindings = type.getBindings(); _intr = config.isAnnotationProcessingEnabled() ? config.getAnnotationIntrospector() : null; _primaryMixin = _config.findMixInClassFor(_class); }