private static List < Class < ? > > lookupAllEventTypes ( Class < ? > eventClass ) { synchronized ( eventTypesCache ) { List < Class < ? > > eventTypes = eventTypesCache . get ( eventClass ) ; if ( eventTypes == null ) { eventTypes = new ArrayList <> ( ) ; Class < ? > clazz = eventClass ; while ( clazz != null ) { eventTypes . add ( clazz ) ; addInterfaces ( eventTypes , clazz . getInterfaces ( ) ) ; clazz = clazz . getSuperclass ( ) ; } eventTypesCache . put ( eventClass , eventTypes ) ; } return eventTypes ; } }
Looks up all Class objects including super classes and interfaces . Should also work for interfaces .