/** * @param name the name of the method * @param parameterTypes the types of the parameters of the method * @return the declared method that matches the name and parameter types of this type. * @throws NoSuchMethodException */ public Method getDeclaredMethod(String name, Class... parameterTypes) throws NoSuchMethodException { for (Method m : getDeclaredMethods()) { if (m.match(name, parameterTypes)) return m; } throw new NoSuchMethodException(); }
/** * @param name the name of the method * @param parameterTypes the types of the parameters of the method * @return the public method that matches the name and parameter types of this type or one of its * super interfaces. * @throws NoSuchMethodException */ public Method getMethod(String name, Class... parameterTypes) throws NoSuchMethodException { Type t = this; while (t != null) { Method[] declMethods = t.getDeclaredMethods(); if (declMethods != null) { for (Method m : declMethods) { if (m.isPublic() && m.match(name, parameterTypes)) return m; } } t = t.getSuperclass(); } throw new NoSuchMethodException(); }