List of utility methods to do Reflection Method Name
Method | getMethod(@Nonnull Class clazz, @Nonnull String methodName, @Nonnull Class... types) get Method Method res = null; try { res = clazz.getDeclaredMethod(methodName, types); if (res != null && (Modifier.isPrivate(res.getModifiers()) || Modifier.isFinal(res.getModifiers()) || Modifier.isStatic(res.getModifiers()))) { res = null; } catch (NoSuchMethodException e) { ... |
Method | getMethod(Class c, String methodName) get Method Method result = null; Method[] methods = c.getMethods(); for (Method m : methods) { String name = m.getName(); if (name.equalsIgnoreCase(methodName)) { result = m; break; return result; |
Method | getMethod(Class c, String name) get Method for (Method method : c.getDeclaredMethods()) { if (method.getName().equals(name)) { return method; throw new IllegalArgumentException("Unknown method '" + name + "' on " + c); |
Method | getMethod(Class cl, String methodName, Class[] paramTypes) get Method Method m = null; try { m = cl.getMethod(methodName, paramTypes); } catch (NoSuchMethodException ex) { return null; Class dclass = m.getDeclaringClass(); if (Modifier.isPublic(dclass.getModifiers())) { ... |
Method | getMethod(Class clazz, String methodName) get Method Method[] methods = clazz.getMethods();
return findUniqueMethodByName(methods, methodName);
|
java.lang.reflect.Method | getMethod(Class clazz, String methodName, Class argType) get Method try { return clazz.getMethod(methodName, new Class[] { argType }); } catch (Throwable ex) { final java.lang.reflect.Method[] ms = clazz.getMethods(); for (java.lang.reflect.Method m : ms) { if (!m.getName().equals(methodName)) continue; ... |
Method | getMethod(Class clazz, String methodName, Class[] classes) get Method try { return clazz.getDeclaredMethod(methodName, classes); } catch (NoSuchMethodException e) { return null; |
Method | getMethod(Class clazz, String methodName, Class[] params) Determines the method with the specified signature via reflection look-up. try { return clazz.getMethod(methodName, params); } catch (Exception ignored) { return null; |
Method | getMethod(Class clazz, String name) get Method Method[] methods = clazz.getMethods(); if (methods == null) { return null; for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (name.equals(method.getName())) { return method; ... |
Method | getMethod(Class clazz, String name, Class>... args) get Method Method method = null; try { method = clazz.getMethod(name, args); } catch (NoSuchMethodException e) { try { method = clazz.getDeclaredMethod(name, args); } catch (NoSuchMethodException e2) { return method; |