@Test public void testResolutionOfMethods() throws Exception { assertThat(methodsOf(TestClass.class)) .contains( TestClass.class.getDeclaredMethod("classMethod"), TestClass.class.getDeclaredMethod("abstractSuperClassMethod"), TestClass.class.getDeclaredMethod("abstractInterfaceMethod"), TestSuperClass.class.getDeclaredMethod("superClassMethod"), TestSuperClass.class.getDeclaredMethod("abstractSuperClassMethod"), TestInterface.class.getMethod("interfaceMethod"), TestInterface.class.getMethod("abstractInterfaceMethod")); }
public static List<Method> methodsOf(Class<?> type) { if (type == null) { throw new IllegalArgumentException("Method argument type must not be null"); } List<Method> methods = new LinkedList<>(); Queue<Class<?>> classes = new LinkedList<>(); classes.add(type); while (!classes.isEmpty()) { Class<?> c = classes.poll(); methods.addAll(asList(c.getDeclaredMethods())); if (c.getSuperclass() != null) { classes.add(c.getSuperclass()); } addAll(classes, c.getInterfaces()); } return methods; }
ReflectionUtil { public static List<Method> methodsOf(Class<?> type) { if (type == null) { throw new IllegalArgumentException("Method argument type must not be null"); } List<Method> methods = new LinkedList<>(); Queue<Class<?>> classes = new LinkedList<>(); classes.add(type); while (!classes.isEmpty()) { Class<?> c = classes.poll(); methods.addAll(asList(c.getDeclaredMethods())); if (c.getSuperclass() != null) { classes.add(c.getSuperclass()); } addAll(classes, c.getInterfaces()); } return methods; } }
ReflectionUtil { public static List<Method> methodsOf(Class<?> type) { if (type == null) { throw new IllegalArgumentException("Method argument type must not be null"); } List<Method> methods = new LinkedList<>(); Queue<Class<?>> classes = new LinkedList<>(); classes.add(type); while (!classes.isEmpty()) { Class<?> c = classes.poll(); methods.addAll(asList(c.getDeclaredMethods())); if (c.getSuperclass() != null) { classes.add(c.getSuperclass()); } addAll(classes, c.getInterfaces()); } return methods; } private  ReflectionUtil(); }
ReflectionUtil { public static List<Method> methodsOf(Class<?> type) { if (type == null) { throw new IllegalArgumentException("Method argument type must not be null"); } List<Method> methods = new LinkedList<>(); Queue<Class<?>> classes = new LinkedList<>(); classes.add(type); while (!classes.isEmpty()) { Class<?> c = classes.poll(); methods.addAll(asList(c.getDeclaredMethods())); if (c.getSuperclass() != null) { classes.add(c.getSuperclass()); } addAll(classes, c.getInterfaces()); } return methods; } private  ReflectionUtil(); static Type getBoundaryOfParametrizedType(final Type type, final Type assigningType); @SuppressWarnings("unchecked") static Collection<K> instantiateCollectionType(Class<T> collectionType, int length); static boolean isInstantiableCollectionType(Class<?> type); static Class<?>[] getInstantiableCollectionTypes(); static Collection<K> instantiateCollectionType(Class<T> collectionType); static List<Method> methodsOf(Class<?> type); static Field findField(Class<?> type, String name); static Field makeAccessible(Field field); static Method makeAccessible(Method method); }
ReflectionUtil { public static List<Method> methodsOf(Class<?> type) { if (type == null) { throw new IllegalArgumentException("Method argument type must not be null"); } List<Method> methods = new LinkedList<>(); Queue<Class<?>> classes = new LinkedList<>(); classes.add(type); while (!classes.isEmpty()) { Class<?> c = classes.poll(); methods.addAll(asList(c.getDeclaredMethods())); if (c.getSuperclass() != null) { classes.add(c.getSuperclass()); } addAll(classes, c.getInterfaces()); } return methods; } private  ReflectionUtil(); static Type getBoundaryOfParametrizedType(final Type type, final Type assigningType); @SuppressWarnings("unchecked") static Collection<K> instantiateCollectionType(Class<T> collectionType, int length); static boolean isInstantiableCollectionType(Class<?> type); static Class<?>[] getInstantiableCollectionTypes(); static Collection<K> instantiateCollectionType(Class<T> collectionType); static List<Method> methodsOf(Class<?> type); static Field findField(Class<?> type, String name); static Field makeAccessible(Field field); static Method makeAccessible(Method method);  }