ReflectionUtils { public static Class getTypeClass(Type type) { Class typeClassClass = null; if (type instanceof Class) { typeClassClass = (Class) type; } else if (type instanceof ParameterizedType) { typeClassClass = (Class) ((ParameterizedType) type).getRawType(); } else if (type instanceof GenericArrayType) { Class<?> arrrayParameter = getTypeClass(((GenericArrayType) type).getGenericComponentType()); if (arrrayParameter != null) { typeClassClass = Array.newInstance(arrrayParameter, 0).getClass(); } } return typeClassClass; } 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);  }
@Test void getTypeClass() { assertSame(TestFieldClass.class, ReflectionUtils.getTypeClass(TestFieldClass.class)); assertSame(TestFieldClass.class, ReflectionUtils .getTypeClass(new DefaultParameterizedType(ReflectionUtilsTest.class, TestFieldClass.class))); }