public static Map < String , List < Method > > getDeclaredMethodsRecursively ( Class clazz ) { final Map < String , List < Method > > current = Arrays . stream ( clazz . getDeclaredMethods ( ) ) . filter ( m -> ! m . getName ( ) . startsWith ( "lambda" ) ) . collect ( Collectors . groupingBy ( Method :: getName ) ) ; for ( Class interfaceClazz : clazz . getInterfaces ( ) ) { getDeclaredMethodsRecursively ( interfaceClazz ) . forEach ( current :: putIfAbsent ) ; } if ( clazz . getSuperclass ( ) != null ) { getDeclaredMethodsRecursively ( clazz . getSuperclass ( ) ) . forEach ( current :: putIfAbsent ) ; } return current ; }
Recursively collects all declared methods of the clazz and it s ancestors .