private static void addMethods ( Set < MethodEntry > methods , Class < ? > clazz , Map < String , Class < ? > > types , Class < ? > parent ) { // validate interface if ( ! clazz . isInterface ( ) ) { throw new IllegalStateException ( "class must be interface: " + clazz ) ; } // loop through each method (only those declared) for ( Method method : clazz . getDeclaredMethods ( ) ) { addMethods ( methods , clazz , types , parent , method ) ; } // recursively add each super interface providing type info if valid addParentMethods ( methods , clazz , types , parent , null ) ; }
Recursive method that adds all applicable methods for the given class which is expected to be an interface . The tree is walked for the class and all super interfaces in recursive fashion to get each available method . Any method that is already defined by the given parent will be ignored . Otherwise the method including any required bridged methods will be added . The specified list of types define the optional type parameters of the given interface class . These types will propogate up the tree as necessary for any super - interfaces that match .