Utilitário estático rápido para obter todos os métodos declarados na hierarquia de classes.
/**
* Gets an array of all methods in a class hierarchy walking up to parent classes
* @param objectClass the class
* @return the methods array
*/
public static Method[] getAllMethodsInHierarchy(Class<?> objectClass) {
Set<Method> allMethods = new HashSet<Method>();
Method[] declaredMethods = objectClass.getDeclaredMethods();
Method[] methods = objectClass.getMethods();
if (objectClass.getSuperclass() != null) {
Class<?> superClass = objectClass.getSuperclass();
Method[] superClassMethods = getAllMethodsInHierarchy(superClass);
allMethods.addAll(Arrays.asList(superClassMethods));
}
allMethods.addAll(Arrays.asList(declaredMethods));
allMethods.addAll(Arrays.asList(methods));
return allMethods.toArray(new Method[allMethods.size()]);
}