@Test void resolveType() { assertEquals( new DefaultParameterizedType(ReflectionUtilsTest.class, TestInterface.class, new DefaultParameterizedType(null, List.class, String.class), Integer.class), ReflectionUtils.resolveType(TestInterface.class, TestClass3.class)); assertEquals(TestInterfaceSimple.class, ReflectionUtils.resolveType(TestInterfaceSimple.class, TestClass4.class)); assertEquals(TestInterfaceSimple.class, ReflectionUtils.resolveType(TestInterfaceSimple.class, new DefaultParameterizedType(ReflectionUtilsTest.class, TestClass4.class, String.class))); }
public static Type resolveType(Type type, Map<TypeVariable, Type> typeMapping) { Type resolvedType = type; if (type instanceof TypeVariable) { if (typeMapping == null) { return null; } resolvedType = typeMapping.get(type); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; Type[] arguments = parameterizedType.getActualTypeArguments(); Type[] resolvedArguments = resolveTypes(arguments, typeMapping); if (resolvedArguments != arguments) { resolvedType = new DefaultParameterizedType(parameterizedType.getOwnerType(), (Class<?>) parameterizedType.getRawType(), resolvedArguments); } else { resolvedType = type; } } return resolvedType; }
ReflectionUtils { public static Type resolveType(Type type, Map<TypeVariable, Type> typeMapping) { Type resolvedType = type; if (type instanceof TypeVariable) { if (typeMapping == null) { return null; } resolvedType = typeMapping.get(type); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; Type[] arguments = parameterizedType.getActualTypeArguments(); Type[] resolvedArguments = resolveTypes(arguments, typeMapping); if (resolvedArguments != arguments) { resolvedType = new DefaultParameterizedType(parameterizedType.getOwnerType(), (Class<?>) parameterizedType.getRawType(), resolvedArguments); } else { resolvedType = type; } } return resolvedType; } }
ReflectionUtils { public static Type resolveType(Type type, Map<TypeVariable, Type> typeMapping) { Type resolvedType = type; if (type instanceof TypeVariable) { if (typeMapping == null) { return null; } resolvedType = typeMapping.get(type); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; Type[] arguments = parameterizedType.getActualTypeArguments(); Type[] resolvedArguments = resolveTypes(arguments, typeMapping); if (resolvedArguments != arguments) { resolvedType = new DefaultParameterizedType(parameterizedType.getOwnerType(), (Class<?>) parameterizedType.getRawType(), resolvedArguments); } else { resolvedType = type; } } return resolvedType; } private  ReflectionUtils(); }
ReflectionUtils { public static Type resolveType(Type type, Map<TypeVariable, Type> typeMapping) { Type resolvedType = type; if (type instanceof TypeVariable) { if (typeMapping == null) { return null; } resolvedType = typeMapping.get(type); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; Type[] arguments = parameterizedType.getActualTypeArguments(); Type[] resolvedArguments = resolveTypes(arguments, typeMapping); if (resolvedArguments != arguments) { resolvedType = new DefaultParameterizedType(parameterizedType.getOwnerType(), (Class<?>) parameterizedType.getRawType(), resolvedArguments); } else { resolvedType = type; } } return resolvedType; } private  ReflectionUtils(); static Collection<Field> getAllFields(Class<?> clazz); static Field getField(Class<?> clazz, String fieldName); static Class getTypeClass(Type type); static void setFieldValue(Object instanceContainingField, String fieldName, Object fieldValue); static Class<?> getLastGenericFieldType(Field field); static Type getLastFieldGenericArgument(Field field); static Type getLastTypeGenericArgument(Type type); static Class<?> getLastGenericClassType(Class clazz, Class filterClass); static Type getGenericClassType(Class clazz, Class filterClass); static Type[] resolveSuperArguments(Type[] parameters, Type childType); static Type[] resolveSuperArguments(Type[] parameters, Class childClass, Type[] childParameters); static Type resolveType(Type type, Map<TypeVariable, Type> typeMapping); static Type resolveType(Type targetType, Type rootType); static Type unserializeType(String serializedType, ClassLoader classLoader); static T getDirectAnnotation(Class<T> annotationClass, AnnotatedElement element); static List<Type> getDirectTypes(Type type); @Unstable static String serializeType(Type type); @Unstable static Collection<Method> getAllMethods(Class<?> clazz); }
ReflectionUtils { public static Type resolveType(Type type, Map<TypeVariable, Type> typeMapping) { Type resolvedType = type; if (type instanceof TypeVariable) { if (typeMapping == null) { return null; } resolvedType = typeMapping.get(type); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; Type[] arguments = parameterizedType.getActualTypeArguments(); Type[] resolvedArguments = resolveTypes(arguments, typeMapping); if (resolvedArguments != arguments) { resolvedType = new DefaultParameterizedType(parameterizedType.getOwnerType(), (Class<?>) parameterizedType.getRawType(), resolvedArguments); } else { resolvedType = type; } } return resolvedType; } private  ReflectionUtils(); static Collection<Field> getAllFields(Class<?> clazz); static Field getField(Class<?> clazz, String fieldName); static Class getTypeClass(Type type); static void setFieldValue(Object instanceContainingField, String fieldName, Object fieldValue); static Class<?> getLastGenericFieldType(Field field); static Type getLastFieldGenericArgument(Field field); static Type getLastTypeGenericArgument(Type type); static Class<?> getLastGenericClassType(Class clazz, Class filterClass); static Type getGenericClassType(Class clazz, Class filterClass); static Type[] resolveSuperArguments(Type[] parameters, Type childType); static Type[] resolveSuperArguments(Type[] parameters, Class childClass, Type[] childParameters); static Type resolveType(Type type, Map<TypeVariable, Type> typeMapping); static Type resolveType(Type targetType, Type rootType); static Type unserializeType(String serializedType, ClassLoader classLoader); static T getDirectAnnotation(Class<T> annotationClass, AnnotatedElement element); static List<Type> getDirectTypes(Type type); @Unstable static String serializeType(Type type); @Unstable static Collection<Method> getAllMethods(Class<?> clazz);  }