com.fasterxml.jackson.databind.type.TypeBindings Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.type.TypeBindings.
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: CollectionModelContentConverter.java From springdoc-openapi with Apache License 2.0 | 5 votes |
/** * Gets entity type. * * @param type the type * @return the entity type */ private Class<?> getEntityType(AnnotatedType type) { Class<?> containerEntityType = ((CollectionType) (type.getType())).getContentType().getRawClass(); if (containerEntityType.isAssignableFrom(EntityModel.class)) { TypeBindings typeBindings = ((CollectionType) type.getType()).getContentType().getBindings() ; if (!CollectionUtils.isEmpty(typeBindings.getTypeParameters())) return typeBindings.getBoundType(0).getRawClass(); } return containerEntityType; }
Example #2
Source File: JacksonAdapter.java From botbuilder-java with MIT License | 5 votes |
private JavaType constructJavaType(final Type type) { if (type instanceof ParameterizedType) { JavaType[] javaTypeArgs = new JavaType[((ParameterizedType) type).getActualTypeArguments().length]; for (int i = 0; i != ((ParameterizedType) type).getActualTypeArguments().length; ++i) { javaTypeArgs[i] = constructJavaType(((ParameterizedType) type).getActualTypeArguments()[i]); } return mapper.getTypeFactory().constructType(type, TypeBindings.create((Class<?>) ((ParameterizedType) type).getRawType(), javaTypeArgs)); } else { return mapper.getTypeFactory().constructType(type); } }
Example #3
Source File: AnnotatedClass.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Constructor will not do any initializations, to allow for * configuring instances differently depending on use cases * * @param type Fully resolved type; may be `null`, but ONLY if no member fields or * methods are to be accessed * @param rawType Type-erased class; pass if no `type` needed or available */ AnnotatedClass(JavaType type, Class<?> rawType, List<JavaType> superTypes, Class<?> primaryMixIn, Annotations classAnnotations, TypeBindings bindings, AnnotationIntrospector aintr, MixInResolver mir, TypeFactory tf) { _type = type; _class = rawType; _superTypes = superTypes; _primaryMixIn = primaryMixIn; _classAnnotations = classAnnotations; _bindings = bindings; _annotationIntrospector = aintr; _mixInResolver = mir; _typeFactory = tf; }
Example #4
Source File: AnnotatedClass.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Constructor (only) used for creating primordial simple types (during bootstrapping) * and array type placeholders where no fields or methods are needed. * * @since 2.9 */ AnnotatedClass(Class<?> rawType) { _type = null; _class = rawType; _superTypes = Collections.emptyList(); _primaryMixIn = null; _classAnnotations = AnnotationCollector.emptyAnnotations(); _bindings = TypeBindings.emptyBindings(); _annotationIntrospector = null; _mixInResolver = null; _typeFactory = null; }
Example #5
Source File: AnnotatedClassResolver.java From lams with GNU General Public License v2.0 | 5 votes |
AnnotatedClassResolver(MapperConfig<?> config, Class<?> cls, MixInResolver r) { _config = config; _type = null; _class = cls; _mixInResolver = r; _bindings = TypeBindings.emptyBindings(); if (config == null) { _intr = null; _primaryMixin = null; } else { _intr = config.isAnnotationProcessingEnabled() ? config.getAnnotationIntrospector() : null; _primaryMixin = _config.findMixInClassFor(_class); } }
Example #6
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 #7
Source File: JacksonAdapter.java From autorest-clientruntime-for-java with MIT License | 5 votes |
private JavaType constructJavaType(final Type type) { if (type instanceof ParameterizedType) { JavaType[] javaTypeArgs = new JavaType[((ParameterizedType) type).getActualTypeArguments().length]; for (int i = 0; i != ((ParameterizedType) type).getActualTypeArguments().length; ++i) { javaTypeArgs[i] = constructJavaType(((ParameterizedType) type).getActualTypeArguments()[i]); } return mapper.getTypeFactory().constructType(type, TypeBindings.create((Class<?>) ((ParameterizedType) type).getRawType(), javaTypeArgs)); } else { return mapper.getTypeFactory().constructType(type); } }
Example #8
Source File: KeeperDeserializer.java From haven-platform with Apache License 2.0 | 5 votes |
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; }
Example #9
Source File: CyclopsTypeModifier.java From cyclops with Apache License 2.0 | 5 votes |
@Override public JavaType modifyType(JavaType type, Type jdkType, TypeBindings bindings, TypeFactory typeFactory) { if (type.isReferenceType() || type.isContainerType()) { return type; } final Class<?> raw = type.getRawClass(); if (raw == Option.class) return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); if (raw == Eval.class) return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); if (raw == Trampoline.class) return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); if (raw == Either.class) return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); if (raw == Value.class) return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); for(Class c : collectionLikeTypes){ if (c.isAssignableFrom(raw)) { // return CollectionType.upgradeFrom(type, type.containedTypeOrUnknown(0)); return CollectionLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } } return type; }
Example #10
Source File: BasicBeanDescription.java From lams with GNU General Public License v2.0 | 4 votes |
@Override @Deprecated // since 2.7 public TypeBindings bindingsForBeanType() { return _type.getBindings(); }
Example #11
Source File: Annotated.java From lams with GNU General Public License v2.0 | 4 votes |
/** * @deprecated Since 2.7 Use {@link #getType()} instead. To be removed from 2.9 */ @Deprecated public final JavaType getType(TypeBindings bogus) { return getType(); }
Example #12
Source File: TypeResolutionContext.java From lams with GNU General Public License v2.0 | 4 votes |
public Basic(TypeFactory tf, TypeBindings b) { _typeFactory = tf; _bindings = b; }
Example #13
Source File: JavaType.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Mutant factory method that will try to create and return a sub-type instance * for known parameterized types; for other types will return `null` to indicate * that no just refinement makes necessary sense, without trying to detect * special status through implemented interfaces. * * @since 2.7 */ public abstract JavaType refine(Class<?> rawType, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces);
Example #14
Source File: JavaType.java From lams with GNU General Public License v2.0 | 2 votes |
/** * @since 2.7 */ public abstract TypeBindings getBindings();
Example #15
Source File: BeanDescription.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Accessor for type bindings that may be needed to fully resolve * types of member object, such as return and argument types of * methods and constructors, and types of fields. * * @deprecated Since 2.7, should not need to access bindings directly */ @Deprecated public abstract TypeBindings bindingsForBeanType();