private static void addParentMethods ( Set < MethodEntry > methods , Class < ? > clazz , Map < String , Class < ? > > types , Class < ? > parent , Method method ) { // recursively add each super interface providing type info if valid Class < ? > [ ] ifaces = clazz . getInterfaces ( ) ; Type [ ] generics = clazz . getGenericInterfaces ( ) ; for ( int i = 0 ; i < ifaces . length ; i ++ ) { Class < ? > iface = ifaces [ i ] ; Type generic = iface ; if ( generics != null && i < generics . length ) { generic = generics [ i ] ; } // check if interface is parameterized and lookup type information // cascading current type information if types match if ( generic instanceof ParameterizedType ) { TypeVariable < ? > [ ] vars = iface . getTypeParameters ( ) ; ParameterizedType ptype = ( ParameterizedType ) generic ; Type [ ] arguments = ptype . getActualTypeArguments ( ) ; // check each parameter for specific type Map < String , Class < ? > > args = new HashMap < String , Class < ? > > ( ) ; for ( int j = 0 ; j < vars . length ; j ++ ) { Type arg = arguments [ j ] ; TypeVariable < ? > var = vars [ j ] ; // check if root type defined and pass type thru Class < ? > root = getRootType ( types , arg ) ; if ( root != null ) { args . put ( var . getName ( ) , root ) ; } } // recursively invoke if ( method == null ) { addMethods ( methods , ( Class < ? > ) ptype . getRawType ( ) , args , parent ) ; } else { addMethods ( methods , ( Class < ? > ) ptype . getRawType ( ) , args , parent , method ) ; } } // normal class, so recursively invoke as is else if ( iface instanceof Class < ? > ) { if ( method == null ) { addMethods ( methods , iface , new HashMap < String , Class < ? > > ( ) , parent ) ; } else { addMethods ( methods , iface , new HashMap < String , Class < ? > > ( ) , parent , method ) ; } } } }
Recursively add all methods walking the interface hiearchy for the given class .