private List < Class < ? > > getAllExternalListeners ( ) { Class < ? > clazz = entityClass ; List < Class < ? > > allListeners = new ArrayList <> ( ) ; boolean stop = false ; while ( ! stop ) { EntityListeners entityListenersAnnotation = clazz . getAnnotation ( EntityListeners . class ) ; if ( entityListenersAnnotation != null ) { Class < ? > [ ] listeners = entityListenersAnnotation . value ( ) ; if ( listeners . length > 0 ) { allListeners . addAll ( 0 , Arrays . asList ( listeners ) ) ; } } boolean excludeDefaultListeners = clazz . isAnnotationPresent ( ExcludeDefaultListeners . class ) ; boolean excludeSuperClassListeners = clazz . isAnnotationPresent ( ExcludeSuperclassListeners . class ) ; if ( excludeDefaultListeners ) { metadata . setExcludeDefaultListeners ( true ) ; } if ( excludeSuperClassListeners ) { metadata . setExcludeSuperClassListeners ( true ) ; } clazz = clazz . getSuperclass ( ) ; stop = excludeSuperClassListeners || clazz == null || ! clazz . isAnnotationPresent ( MappedSuperClass . class ) ; } return allListeners ; }
Inspects the entity hierarchy and returns all external listeners .