@Test public void testFindMethodByArity3() throws Exception { ReflectionTestFunctionLibrary library = new ReflectionTestFunctionLibrary(); Method method = ReflectionUtil.findMethod(library, "m", 3); assertNotNull("No method", method); method.invoke(library, "foo", 1, 2L); assertCalled(library, "m3"); }
public static Method findMethod(Object object, String methodName, int arity) { for (Method method: object.getClass().getMethods()) { if (method.getName().equals(methodName) && method.getParameterTypes().length == arity && !method.isVarArgs()) { return method; } } return null; }
ReflectionUtil { public static Method findMethod(Object object, String methodName, int arity) { for (Method method: object.getClass().getMethods()) { if (method.getName().equals(methodName) && method.getParameterTypes().length == arity && !method.isVarArgs()) { return method; } } return null; } }
ReflectionUtil { public static Method findMethod(Object object, String methodName, int arity) { for (Method method: object.getClass().getMethods()) { if (method.getName().equals(methodName) && method.getParameterTypes().length == arity && !method.isVarArgs()) { return method; } } return null; }  }
ReflectionUtil { public static Method findMethod(Object object, String methodName, int arity) { for (Method method: object.getClass().getMethods()) { if (method.getName().equals(methodName) && method.getParameterTypes().length == arity && !method.isVarArgs()) { return method; } } return null; }  static T getJavaProperty(Object object, String propertyName, Class<T> propetyClass); static boolean hasJavaProperty(Object object, String propertyName); static Method findGetter(Object object, String propertyName); static Method findMethod(Object object, String methodName, int arity); static Method findMethod(Object object, String methodName, List<?> argList); static Method findVarArgsMethod(Object object, String methodName); static Object invokeMethod(Object object, String methodName, List<?> argList); static String debugDumpArgList(List<?> argList); }
ReflectionUtil { public static Method findMethod(Object object, String methodName, int arity) { for (Method method: object.getClass().getMethods()) { if (method.getName().equals(methodName) && method.getParameterTypes().length == arity && !method.isVarArgs()) { return method; } } return null; }  static T getJavaProperty(Object object, String propertyName, Class<T> propetyClass); static boolean hasJavaProperty(Object object, String propertyName); static Method findGetter(Object object, String propertyName); static Method findMethod(Object object, String methodName, int arity); static Method findMethod(Object object, String methodName, List<?> argList); static Method findVarArgsMethod(Object object, String methodName); static Object invokeMethod(Object object, String methodName, List<?> argList); static String debugDumpArgList(List<?> argList);  }