List of utility methods to do Reflection Method Name
Method | getMethod(Class cls, String methodName, Class[] params) get Method return cls.getMethod(methodName, params);
|
Method | getMethod(Class clz, String methodName, Class expectedTypes[]) get Method Method method = null; try { method = clz.getMethod(methodName, expectedTypes); } catch (NoSuchMethodException e) { Method methods[] = clz.getMethods(); for (int i = 0; i < methods.length; i++) { Method _method = methods[i]; if (!_method.getName().equals(methodName) ... |
Method | getMethod(Class klazz, String[] methodNames, int argCount) get Method if (klazz == null) { return null; for (String method : methodNames) { try { for (Method m : getAllMethods(klazz)) { if (m.getName().equals(method) && (argCount == -1 || m.getParameterTypes().length == argCount)) { ... |
Method | getMethod(Class objClass, String methodName, Class argClass) get Method Class argClasses[] = (argClass == null) ? null : new Class[] { argClass }; return getMethod(objClass, methodName, argClasses); |
Method | getMethod(Class serviceClass, String methodName, Class>... mapClass) get Method return null;
|
Method | getMethod(Class targetClass, String methodName, Class[] paramTypes) get Method Method method = null; NoSuchMethodException nsmex = null; for (Class clazz = targetClass; clazz != null; clazz = clazz.getSuperclass()) try { method = clazz.getDeclaredMethod(methodName, paramTypes); break; } catch (NoSuchMethodException ex) { if (nsmex == null) ... |
Method | getMethod(Class targetClass, String name, Class paramClass) Get the method with the given name and with a single argument of the type specified by paramClass. if (paramClass == null) { return getMethod(targetClass, name, EMPTY_CLASS_ARRAY); } else { Class[] paramClasses = new Class[1]; paramClasses[0] = paramClass; return getMethod(targetClass, name, paramClasses); |
Method | getMethod(Class targetClass, String targetMethodName) get Method return getMethod(targetClass, targetMethodName, null);
|
Method | getMethod(Class theClass, String propertyName) get Method Method[] methods = theClass.getDeclaredMethods(); Method.setAccessible(methods, true); for (Method method : methods) { if (method.getParameterTypes().length != 0) { continue; if (method.isBridge()) { continue; ... |
Method | getMethod(Class type, String name, Class[] paramTypes) Returns Method object for specified method, which should always exist. try { return type.getMethod(name, paramTypes); } catch (NoSuchMethodException e) { throw new AssertionError(e); |