List of utility methods to do Reflection Method Parameter
List | getMethodsWith(Class> c, Class>... parameters) Returns a method from a class with the given parameters List<Class<?>> params = Arrays.asList(parameters); List<Method> methods = new ArrayList<>(); for (Method m : c.getMethods()) { for (Class<?> p : m.getParameterTypes()) { if (params.contains(p)) methods.add(m); return methods; |
Method | getMethodUp(Class> type, String name, Class>... parameterTypes) get Method Up Method method = null; for (Class<?> clazz = type; clazz != Object.class; clazz = clazz.getSuperclass()) { try { method = clazz.getDeclaredMethod(name, parameterTypes); break; } catch (Exception e) { return method; |
Method | getMethodWithParameter(Class> declaringClass, Class> parameterClass) get Method With Parameter Method[] methods = declaringClass.getMethods(); for (Method method : methods) { Class<?>[] parameters = method.getParameterTypes(); if (parameters.length == 1 && parameters[0].equals(parameterClass)) { return method; return null; ... |