AnnotatedTypeVariableImpl(TypeVariable<?> type) { this(type, type.getAnnotations()); }
TypeVariableImpl(TypeVariable<D> variable, AnnotatedType[] bounds) { this(variable, variable.getAnnotations(), bounds); }
/** * Gets the type parameter for a given type that is the value for a given type variable. * For example, with {@code class StringList implements List<String>}, * {@code getTypeParameter(StringList.class, Collection.class.getTypeParameters()[0])} * returns {@code String}. * * @param type The type to inspect. * @param variable The type variable to find the value for. * @return The type parameter for the given variable. Or null if type is not a subtype of the * type that declares the variable, or if the variable isn't known (because of raw types). */ public static AnnotatedType getTypeParameter(AnnotatedType type, TypeVariable<? extends Class<?>> variable) { Class<?> clazz = variable.getGenericDeclaration(); AnnotatedType superType = getExactSuperType(type, clazz); if (superType instanceof AnnotatedParameterizedType) { int index = Arrays.asList(clazz.getTypeParameters()).indexOf(variable); AnnotatedType resolvedVarType = ((AnnotatedParameterizedType)superType).getAnnotatedActualTypeArguments()[index]; return updateAnnotations(resolvedVarType, variable.getAnnotations()); } else { return null; } }
AnnotatedTypeVariable variable = (AnnotatedTypeVariable) type; AnnotatedType[] bounds = map(variable.getAnnotatedBounds()); Annotation[] merged = merge(variable.getAnnotations(), tv.getAnnotations()); TypeVariableImpl v = new TypeVariableImpl<>(tv, merged, bounds); return new AnnotatedTypeVariableImpl(v, merged, bounds); Annotation[] merged = merge(type.getAnnotations(), tv.getAnnotations(), map.get(tv).getAnnotations(), varFromClass.getAnnotations()); return updateAnnotations(map.get(tv), merged); } else if (type instanceof AnnotatedParameterizedType) { for (int i = 0; i < typeParameters.length; i++) { AnnotatedType typeParameter = map(pType.getAnnotatedActualTypeArguments()[i]); typeParameters[i] = updateAnnotations(typeParameter, raw.getTypeParameters()[i].getAnnotations());
for (int i = 0; i < params.length; i++) { AnnotatedType param = annotate(parameterized.getActualTypeArguments()[i], cache); params[i] = updateAnnotations(param, erase(type).getTypeParameters()[i].getAnnotations());