/** * Factory method to call when no special {@link JavaType} is needed, * no generic parameters are passed. Default implementation may check * pre-constructed values for "well-known" types, but if none found * will simply call {@link #_newSimpleType} * * @since 2.7 */ protected JavaType _constructSimple(Class<?> raw, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) { if (bindings.isEmpty()) { JavaType result = _findWellKnownSimple(raw); if (result != null) { return result; } } return _newSimpleType(raw, bindings, superClass, superInterfaces); }
/** * @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 for constructing a {@link CollectionType}. *<p> * NOTE: type modifiers are NOT called on Collection type itself; but are called * for contained types. */ public CollectionType constructCollectionType(Class<? extends Collection> collectionClass, JavaType elementType) { TypeBindings bindings = TypeBindings.createIfNeeded(collectionClass, elementType); CollectionType result = (CollectionType) _fromClass(null, collectionClass, bindings); // 17-May-2017, tatu: As per [databind#1415], we better verify bound values if (but only if) // type being resolved was non-generic (i.e.element type was ignored) if (bindings.isEmpty() && (elementType != null)) { JavaType t = result.findSuperType(Collection.class); JavaType realET = t.getContentType(); if (!realET.equals(elementType)) { throw new IllegalArgumentException(String.format( "Non-generic Collection class %s did not resolve to something with element type %s but %s ", ClassUtil.nameOf(collectionClass), elementType, realET)); } } return result; }
/** * Method for constructing a {@link MapType} instance *<p> * NOTE: type modifiers are NOT called on constructed type itself; but are called * for contained types. */ public MapType constructMapType(Class<? extends Map> mapClass, JavaType keyType, JavaType valueType) { TypeBindings bindings = TypeBindings.createIfNeeded(mapClass, new JavaType[] { keyType, valueType }); MapType result = (MapType) _fromClass(null, mapClass, bindings); // 17-May-2017, tatu: As per [databind#1415], we better verify bound values if (but only if) // type being resolved was non-generic (i.e.element type was ignored) if (bindings.isEmpty()) { JavaType t = result.findSuperType(Map.class); JavaType realKT = t.getKeyType(); if (!realKT.equals(keyType)) { throw new IllegalArgumentException(String.format( "Non-generic Map class %s did not resolve to something with key type %s but %s ", ClassUtil.nameOf(mapClass), keyType, realKT)); } JavaType realVT = t.getContentType(); if (!realVT.equals(valueType)) { throw new IllegalArgumentException(String.format( "Non-generic Map class %s did not resolve to something with value type %s but %s ", ClassUtil.nameOf(mapClass), valueType, realVT)); } } return result; }
if (baseType.getBindings().isEmpty()) { newType = _fromClass(null, subclass, EMPTY_BINDINGS); break;
if ((bindings == null) || bindings.isEmpty()) { key = rawType; } else {
/** * Factory method to call when no special {@link JavaType} is needed, * no generic parameters are passed. Default implementation may check * pre-constructed values for "well-known" types, but if none found * will simply call {@link #_newSimpleType} * * @since 2.7 */ protected JavaType _constructSimple(Class<?> raw, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) { if (bindings.isEmpty()) { JavaType result = _findWellKnownSimple(raw); if (result != null) { return result; } } return _newSimpleType(raw, bindings, superClass, superInterfaces); }
/** * Factory method to call when no special {@link JavaType} is needed, * no generic parameters are passed. Default implementation may check * pre-constructed values for "well-known" types, but if none found * will simply call {@link #_newSimpleType} * * @since 2.7 */ protected JavaType _constructSimple(Class<?> raw, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) { if (bindings.isEmpty()) { JavaType result = _findWellKnownSimple(raw); if (result != null) { return result; } } return _newSimpleType(raw, bindings, superClass, superInterfaces); }
/** * @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); }
/** * @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 = TypeBindings.emptyBindings(); } 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 for constructing a {@link CollectionType}. *<p> * NOTE: type modifiers are NOT called on Collection type itself; but are called * for contained types. */ public CollectionType constructCollectionType(Class<? extends Collection> collectionClass, JavaType elementType) { TypeBindings bindings = TypeBindings.createIfNeeded(collectionClass, elementType); CollectionType result = (CollectionType) _fromClass(null, collectionClass, bindings); // 17-May-2017, tatu: As per [databind#1415], we better verify bound values if (but only if) // type being resolved was non-generic (i.e.element type was ignored) if (bindings.isEmpty() && (elementType != null)) { JavaType t = result.findSuperType(Collection.class); JavaType realET = t.getContentType(); if (!realET.equals(elementType)) { throw new IllegalArgumentException(String.format( "Non-generic Collection class %s did not resolve to something with element type %s but %s ", ClassUtil.nameOf(collectionClass), elementType, realET)); } } return result; }
/** * Method for constructing a {@link MapType} instance *<p> * NOTE: type modifiers are NOT called on constructed type itself; but are called * for contained types. */ public MapType constructMapType(Class<? extends Map> mapClass, JavaType keyType, JavaType valueType) { TypeBindings bindings = TypeBindings.createIfNeeded(mapClass, new JavaType[] { keyType, valueType }); MapType result = (MapType) _fromClass(null, mapClass, bindings); // 17-May-2017, tatu: As per [databind#1415], we better verify bound values if (but only if) // type being resolved was non-generic (i.e.element type was ignored) if (bindings.isEmpty()) { JavaType t = result.findSuperType(Map.class); JavaType realKT = t.getKeyType(); if (!realKT.equals(keyType)) { throw new IllegalArgumentException(String.format( "Non-generic Map class %s did not resolve to something with key type %s but %s ", ClassUtil.nameOf(mapClass), keyType, realKT)); } JavaType realVT = t.getContentType(); if (!realVT.equals(valueType)) { throw new IllegalArgumentException(String.format( "Non-generic Map class %s did not resolve to something with value type %s but %s ", ClassUtil.nameOf(mapClass), valueType, realVT)); } } return result; }
if (baseType.getBindings().isEmpty()) { newType = _fromClass(null, subclass, EMPTY_BINDINGS); break;
if (baseType.getBindings().isEmpty()) { newType = _fromClass(null, subclass, TypeBindings.emptyBindings()); break;
if ((bindings == null) || bindings.isEmpty()) { key = rawType; } else {
if ((bindings == null) || bindings.isEmpty()) { key = rawType; } else {