Java Code Examples for com.fasterxml.jackson.databind.JavaType#getBindings()
The following examples show how to use
com.fasterxml.jackson.databind.JavaType#getBindings() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResponseSupportConverter.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) { JavaType javaType = Json.mapper().constructType(type.getType()); if (javaType != null) { Class<?> cls = javaType.getRawClass(); if (isResponseTypeWrapper(cls)) { JavaType innerType = javaType.getBindings().getBoundType(0); if (innerType == null) return new StringSchema(); else if (innerType.getBindings() != null && isResponseTypeWrapper(innerType.getRawClass())) { type = new AnnotatedType(innerType).jsonViewAnnotation(type.getJsonViewAnnotation()).ctxAnnotations(type.getCtxAnnotations()).resolveAsRef(true); return this.resolve(type, context, chain); } else type = new AnnotatedType(innerType).jsonViewAnnotation(type.getJsonViewAnnotation()).ctxAnnotations((type.getCtxAnnotations())).resolveAsRef(true); } else if (isResponseTypeToIgnore(cls)) return null; } return (chain.hasNext()) ? chain.next().resolve(type, context, chain) : null; }
Example 2
Source File: WebFluxSupportConverter.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) { JavaType javaType = Json.mapper().constructType(type.getType()); if (javaType != null) { Class<?> cls = javaType.getRawClass(); if (isFluxTypeWrapper(cls)) { JavaType innerType = javaType.getBindings().getBoundType(0); if (innerType == null) return new StringSchema(); else if (innerType.getBindings() != null && isResponseTypeWrapper(innerType.getRawClass())) { type = new AnnotatedType(innerType).jsonViewAnnotation(type.getJsonViewAnnotation()).resolveAsRef(true); return this.resolve(type, context, chain); } else { ArrayType arrayType = ArrayType.construct(innerType, null); type = new AnnotatedType(arrayType).jsonViewAnnotation(type.getJsonViewAnnotation()).resolveAsRef(true); } } } return (chain.hasNext()) ? chain.next().resolve(type, context, chain) : null; }
Example 3
Source File: TypeFactory.java From lams with GNU General Public License v2.0 | 6 votes |
/** * @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); }
Example 4
Source File: AnnotatedClassResolver.java From lams with GNU General Public License v2.0 | 5 votes |
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); }
Example 5
Source File: EclipseMapDeserializers.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
MapDeserializer<T, I, K, V> createDeserializer(JavaType type) { List<JavaType> typeParameters = null; TypeBindings bindings = type.getBindings(); if (bindings != null) { typeParameters = bindings.getTypeParameters(); } JavaType keyType; JavaType valueType; if (typeParameters != null && !typeParameters.isEmpty()) { if (refKey && refValue) { if (typeParameters.size() != 2) { throw new IllegalStateException( "type parameters: " + typeParameters + ", expected exactly two"); } } else if (refKey || refValue) { if (typeParameters.size() != 1) { throw new IllegalStateException( "type parameters: " + typeParameters + ", expected exactly one"); } } keyType = refKey ? typeParameters.get(0) : null; valueType = refValue ? typeParameters.get(typeParameters.size() - 1) : null; } else { // `type` is a raw type keyType = TypeFactory.unknownType(); valueType = TypeFactory.unknownType(); } return MapDeserializer.create(keyType, valueType, typeHandlerPair, finish); }
Example 6
Source File: TypeFactory.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Factory method that can be used if type information is passed * as Java typing returned from <code>getGenericXxx</code> methods * (usually for a return or argument type). */ protected JavaType _fromAny(ClassStack context, Type type, TypeBindings bindings) { JavaType resultType; // simple class? if (type instanceof Class<?>) { // Important: remove possible bindings since this is type-erased thingy resultType = _fromClass(context, (Class<?>) type, EMPTY_BINDINGS); } // But if not, need to start resolving. else if (type instanceof ParameterizedType) { resultType = _fromParamType(context, (ParameterizedType) type, bindings); } else if (type instanceof JavaType) { // [databind#116] // no need to modify further if we already had JavaType return (JavaType) type; } else if (type instanceof GenericArrayType) { resultType = _fromArrayType(context, (GenericArrayType) type, bindings); } else if (type instanceof TypeVariable<?>) { resultType = _fromVariable(context, (TypeVariable<?>) type, bindings); } else if (type instanceof WildcardType) { resultType = _fromWildcard(context, (WildcardType) type, bindings); } else { // sanity check throw new IllegalArgumentException("Unrecognized Type: "+((type == null) ? "[null]" : type.toString())); } /* 21-Feb-2016, nateB/tatu: as per [databind#1129] (applied for 2.7.2), * we do need to let all kinds of types to be refined, esp. for Scala module. */ if (_modifiers != null) { TypeBindings b = resultType.getBindings(); if (b == null) { b = EMPTY_BINDINGS; } for (TypeModifier mod : _modifiers) { JavaType t = mod.modifyType(resultType, type, b, this); if (t == null) { throw new IllegalStateException(String.format( "TypeModifier %s (of type %s) return null for type %s", mod, mod.getClass().getName(), resultType)); } resultType = t; } } return resultType; }
Example 7
Source File: BeanBuilder.java From jackson-modules-base with Apache License 2.0 | 4 votes |
protected TypeResolutionContext buildTypeContext(JavaType ctxtType) { return new TypeResolutionContext.Basic(_typeFactory, ctxtType.getBindings()); }