/** * Process the property. * * @param clazz * The type. * @param genericParameter * The generic parameter number. * @param propertyHierarchy * The property hierachy. * @param property * The property. * @return The property type. */ private static Type processProperty(final Class<?> clazz, final int genericParameter, final Deque<? extends Member> propertyHierarchy, final Member property) { Type result = null; // Get the type path. final Type genericType = property.getGenericType(); final Deque<Type> typePath = GenericsUtil.findTypePath(genericType, clazz); // This field is part of the path. if (genericType instanceof ParameterizedType) { typePath.push(genericType); } if (!typePath.isEmpty()) { // Trace to root type. result = GenericsUtil.traceType(property, typePath, genericParameter); result = GenericsUtil.handleTypeVariable(propertyHierarchy, property, result); } return result; }
/** * Finds originating type for this field. * * @param properties * The fields to look through. * @return The true type. */ public static Type getRealType(final Deque<? extends Member> properties) { final Member property = properties.pop(); final Type fieldType = property.getGenericType(); Type result = null; if (fieldType instanceof TypeVariable) { final TypeVariable<?> typeVariable = (TypeVariable<?>) fieldType; final Class<?> declaringType = GenericsUtil.getDeclaringClass(property.getDeclaringType(), typeVariable); final TypeVariable<?> superTypeVariable = GenericsUtil.getSuperDeclaration(property, typeVariable); final int param = GenericsUtil.getRealParameter(superTypeVariable); result = GenericsUtil.getPropertyGenericType(declaringType, param, properties); } else if (fieldType instanceof Class) { result = fieldType; } else if (fieldType instanceof ParameterizedType) { final ParameterizedType pType = (ParameterizedType) fieldType; result = pType.getRawType(); } return result; }
final Type type = property.getGenericType(); if (type instanceof ParameterizedType) { final ParameterizedType parameterizedType = (ParameterizedType) type;