@ SuppressWarnings ( "unchecked" ) Class < ? > [ ] getAllInterfacesAndClasses ( Class < ? > [ ] classes ) { if ( 0 == classes . length ) { return classes ; } else { List < Class < ? > > extendedClasses = new ArrayList < Class < ? > > ( ) ; // all interfaces hierarchy for ( Class < ? > clazz : classes ) { if ( clazz != null ) { Class < ? > [ ] interfaces = clazz . getInterfaces ( ) ; if ( interfaces != null ) { extendedClasses . addAll ( Arrays . asList ( interfaces ) ) ; } Class < ? > superclass = clazz . getSuperclass ( ) ; if ( superclass != null && superclass != Object . class ) { extendedClasses . addAll ( Arrays . asList ( superclass ) ) ; } } } //Class::getInterfaces() gets only interfaces/classes implemented/extended directly by a given class. //We need to walk the whole way up the tree. return ( Class [ ] ) ArrayUtils . addAll ( classes , getAllInterfacesAndClasses ( extendedClasses . toArray ( new Class [ extendedClasses . size ( ) ] ) ) ) ; } }
possibly contain the declaration of the annotated method we re looking for .