@Test public void testMethodParameterTypeToString() { Method method = null; for (Method m : MethodParameterType.class.getDeclaredMethods()) { method = m; } Type[] types = method.getGenericParameterTypes(); assertEquals(Object.class, ReflectionUtil.getRawType(types[0], MethodParameterType.class)); assertEquals(String.class, ReflectionUtil.getRawType(types[1], MethodParameterType.class)); assertEquals(List.class, ReflectionUtil.getRawType(types[2], MethodParameterType.class)); assertEquals(List.class, ReflectionUtil.getRawType(types[3], MethodParameterType.class)); assertEquals(List.class, ReflectionUtil.getRawType(types[4], MethodParameterType.class)); assertEquals(Long.class, ReflectionUtil.getRawType(types[0], Mimple.class)); assertEquals(String.class, ReflectionUtil.getRawType(types[1], Mimple.class)); assertEquals(List.class, ReflectionUtil.getRawType(types[2], Mimple.class)); assertEquals(List.class, ReflectionUtil.getRawType(types[3], Mimple.class)); assertEquals(List.class, ReflectionUtil.getRawType(types[4], Mimple.class)); }
public static Class<?> getRawType(Type type) { return getRawType(type, null); }
ReflectionUtil { public static Class<?> getRawType(Type type) { return getRawType(type, null); } }
ReflectionUtil { public static Class<?> getRawType(Type type) { return getRawType(type, null); }  }
ReflectionUtil { public static Class<?> getRawType(Type type) { return getRawType(type, null); }  static Method[] getAllMethodsOfClass(final Class<?> clazz); static Method[] getAllMethodsOfClass(Class<?> clazz, boolean accessible); static Method[] getAllInstanceMethods(final Class<?> clazz); static Method[] getAllInstanceMethods(Class<?> clazz, boolean accessible); static List<A> findAllMethodAnnotation(Class<T> clazz, Class<A> annotationType); static List<Method> getAnnotationMethods(Class<T> clazz, Class<A> annotationType); static Object invokeMethod(Method method, Object target, Object...args); static Object invokeMethod(Object object, String methodName, Object[] args, Class<?>...parameterTypes); static Object invokeStaticMethod(Class<?> clazz, String methodName, Object[] args, Class<?>...parameterTypes); static Method getMethod(Class<?> clazz, String methodName, Class<?>...parameterTypes); static Method getMethod(Object object, String methodName, Class<?>...parameterTypes); static Method[] getAccessibleMethods(Class<?> clazz); static Method[] getAccessibleMethods(Class<?> clazz, Class<?> limit); static boolean hasAnnotation(Method method, Class<A> annotationType); static Field[] getAllFieldsOfClass(Class<?> clazz); static Field[] getAllInstanceFields(Class<?> clazz); static Field[] getAllFieldsOfClass(Class<?> clazz, boolean accessible); static Field[] getAllFieldsOfClass(Object object); static Field[] getAllFieldsOfClass(Object object, boolean accessible); static Field[] getAllInstanceFields(Class<?> clazz, boolean accessible); static Field[] getAllInstanceFields(Object object); static Field[] getAllInstanceFields(Object object, boolean accessible); static Field[] getInstanceFields(Class<?> clazz, String[] includes); static Field[] getAnnotationFields(Class<?> clazz, Class<? extends Annotation> annotationClass); static Field getField(Object object, String fieldName); static Field getField(Class<?> clazz, String fieldName); @Deprecated static Field getFieldOfClass(Object object, String fieldName); static Field getField(Object object, String fieldName, boolean accessible); static Field getField(Class<?> clazz, String fieldName, boolean accessible); @Deprecated static Field getFieldOfClass(Class<?> clazz, String fieldName); @Deprecated static Field getFieldOfClass(Object object, String fieldName, boolean accessible); static Field[] getAccessibleFields(Class<?> clazz); static Field[] getAccessibleFields(Class<?> clazz, Class<?> limit); static T readField(Field field, Object target); static Object readField(String fieldName, Object target); static void writeField(Field field, Object target, Object value); static void writeField(Object target, String fieldName, Object value); static Object readStaticField(Field field); static Object readStaticField(Class<?> clazz, String fieldName); static void writeStaticField(Field field, Object value); static void writeStaticField(Class<?> clazz, String fieldName, Object value); static boolean notWriter(Field field); static boolean isFinal(Field field); static boolean hasSuperClass(Class<?> clazz); static boolean hasAnnotation(Field field, Class<A> annotationType); static Class<?> getComponentType(Class<?> clazz); static Class<?> getComponentType(Class<?> clazz, int index); static Class<?>[] getComponentTypes(Class<?> clazz); static Class<?>[] getComponentTypesRecursion(Class<?> clazz); static Class<?> getComponentTypeRecursion(Class<?> clazz); static Class<?> getComponentTypeRecursion(Class<?> clazz, int index); static Class<?> getComponentType(Type type); static Class<?> getComponentType(Type type, Class<?> implClass); static Class<?>[] getComponentTypes(Type type); static Class<?>[] getComponentTypes(Type type, Class<?> implClass); static Class<?>[] getGenericSuperTypes(Class<?> type); static Class<?> getGenericSuperType(Class<?> type); static Class<?> getRawType(Type type); static Class<?> getRawType(Type type, Class<?> implClass); static Type resolveVariable(TypeVariable<?> variable, final Class<?> implClass); static boolean isAccessible(Member m); static boolean isPublic(Member m); static void forceAccess(AccessibleObject object); }
ReflectionUtil { public static Class<?> getRawType(Type type) { return getRawType(type, null); }  static Method[] getAllMethodsOfClass(final Class<?> clazz); static Method[] getAllMethodsOfClass(Class<?> clazz, boolean accessible); static Method[] getAllInstanceMethods(final Class<?> clazz); static Method[] getAllInstanceMethods(Class<?> clazz, boolean accessible); static List<A> findAllMethodAnnotation(Class<T> clazz, Class<A> annotationType); static List<Method> getAnnotationMethods(Class<T> clazz, Class<A> annotationType); static Object invokeMethod(Method method, Object target, Object...args); static Object invokeMethod(Object object, String methodName, Object[] args, Class<?>...parameterTypes); static Object invokeStaticMethod(Class<?> clazz, String methodName, Object[] args, Class<?>...parameterTypes); static Method getMethod(Class<?> clazz, String methodName, Class<?>...parameterTypes); static Method getMethod(Object object, String methodName, Class<?>...parameterTypes); static Method[] getAccessibleMethods(Class<?> clazz); static Method[] getAccessibleMethods(Class<?> clazz, Class<?> limit); static boolean hasAnnotation(Method method, Class<A> annotationType); static Field[] getAllFieldsOfClass(Class<?> clazz); static Field[] getAllInstanceFields(Class<?> clazz); static Field[] getAllFieldsOfClass(Class<?> clazz, boolean accessible); static Field[] getAllFieldsOfClass(Object object); static Field[] getAllFieldsOfClass(Object object, boolean accessible); static Field[] getAllInstanceFields(Class<?> clazz, boolean accessible); static Field[] getAllInstanceFields(Object object); static Field[] getAllInstanceFields(Object object, boolean accessible); static Field[] getInstanceFields(Class<?> clazz, String[] includes); static Field[] getAnnotationFields(Class<?> clazz, Class<? extends Annotation> annotationClass); static Field getField(Object object, String fieldName); static Field getField(Class<?> clazz, String fieldName); @Deprecated static Field getFieldOfClass(Object object, String fieldName); static Field getField(Object object, String fieldName, boolean accessible); static Field getField(Class<?> clazz, String fieldName, boolean accessible); @Deprecated static Field getFieldOfClass(Class<?> clazz, String fieldName); @Deprecated static Field getFieldOfClass(Object object, String fieldName, boolean accessible); static Field[] getAccessibleFields(Class<?> clazz); static Field[] getAccessibleFields(Class<?> clazz, Class<?> limit); static T readField(Field field, Object target); static Object readField(String fieldName, Object target); static void writeField(Field field, Object target, Object value); static void writeField(Object target, String fieldName, Object value); static Object readStaticField(Field field); static Object readStaticField(Class<?> clazz, String fieldName); static void writeStaticField(Field field, Object value); static void writeStaticField(Class<?> clazz, String fieldName, Object value); static boolean notWriter(Field field); static boolean isFinal(Field field); static boolean hasSuperClass(Class<?> clazz); static boolean hasAnnotation(Field field, Class<A> annotationType); static Class<?> getComponentType(Class<?> clazz); static Class<?> getComponentType(Class<?> clazz, int index); static Class<?>[] getComponentTypes(Class<?> clazz); static Class<?>[] getComponentTypesRecursion(Class<?> clazz); static Class<?> getComponentTypeRecursion(Class<?> clazz); static Class<?> getComponentTypeRecursion(Class<?> clazz, int index); static Class<?> getComponentType(Type type); static Class<?> getComponentType(Type type, Class<?> implClass); static Class<?>[] getComponentTypes(Type type); static Class<?>[] getComponentTypes(Type type, Class<?> implClass); static Class<?>[] getGenericSuperTypes(Class<?> type); static Class<?> getGenericSuperType(Class<?> type); static Class<?> getRawType(Type type); static Class<?> getRawType(Type type, Class<?> implClass); static Type resolveVariable(TypeVariable<?> variable, final Class<?> implClass); static boolean isAccessible(Member m); static boolean isPublic(Member m); static void forceAccess(AccessibleObject object);  }