@Test public void testFindMethod() { Method m = ReflectionUtils.findMethod(TestDocument.class, "getName"); assertNotNull(m); assertEquals("getName", m.getName()); }
public static Method findMethod(Class<?> clazz, String name) { for (Method me : clazz.getDeclaredMethods()) { if (me.getName().equalsIgnoreCase(name)) { return me; } } if (clazz.getSuperclass() != null) { return findMethod(clazz.getSuperclass(), name); } return null; }
ReflectionUtils { public static Method findMethod(Class<?> clazz, String name) { for (Method me : clazz.getDeclaredMethods()) { if (me.getName().equalsIgnoreCase(name)) { return me; } } if (clazz.getSuperclass() != null) { return findMethod(clazz.getSuperclass(), name); } return null; } }
ReflectionUtils { public static Method findMethod(Class<?> clazz, String name) { for (Method me : clazz.getDeclaredMethods()) { if (me.getName().equalsIgnoreCase(name)) { return me; } } if (clazz.getSuperclass() != null) { return findMethod(clazz.getSuperclass(), name); } return null; }  }
ReflectionUtils { public static Method findMethod(Class<?> clazz, String name) { for (Method me : clazz.getDeclaredMethods()) { if (me.getName().equalsIgnoreCase(name)) { return me; } } if (clazz.getSuperclass() != null) { return findMethod(clazz.getSuperclass(), name); } return null; }  static T findAnnotation(Class<?> clazz, Class<T> annotationClass, Predicate<Field> p); static Collection<Field> eachField(Class<?> clazz, Predicate<Field> p); static Collection<Method> eachMethod(Class<?> clazz, Predicate<Method> p); static void eachAnnotation(Class<?> clazz,
			Class<T> annotationClass, Predicate<T> p); static Method findMethod(Class<?> clazz, String name); static boolean hasAnnotation(AnnotatedElement e, Class<? extends Annotation> annotationClass); }
ReflectionUtils { public static Method findMethod(Class<?> clazz, String name) { for (Method me : clazz.getDeclaredMethods()) { if (me.getName().equalsIgnoreCase(name)) { return me; } } if (clazz.getSuperclass() != null) { return findMethod(clazz.getSuperclass(), name); } return null; }  static T findAnnotation(Class<?> clazz, Class<T> annotationClass, Predicate<Field> p); static Collection<Field> eachField(Class<?> clazz, Predicate<Field> p); static Collection<Method> eachMethod(Class<?> clazz, Predicate<Method> p); static void eachAnnotation(Class<?> clazz,
			Class<T> annotationClass, Predicate<T> p); static Method findMethod(Class<?> clazz, String name); static boolean hasAnnotation(AnnotatedElement e, Class<? extends Annotation> annotationClass);  }