public < T > void handleEvent ( final T event ) throws EventException { final Class < ? > type = event . getClass ( ) ; if ( ! this . cachedListeners . containsKey ( event . getClass ( ) ) ) { this . cachedListeners . put ( type , new LinkedList < ListenerInstancePair < ? > > ( ) ) ; for ( final ListenerInstancePair < ? > listener : this . listeners ) { final Type observableType = GenericsUtil . getEntityGenericType ( listener . listener . getClass ( ) , 0 , Listener . class ) ; final Class < ? > observable = GenericsUtil . guessClazz ( observableType ) ; if ( observable . isAssignableFrom ( type ) ) { this . cachedListeners . get ( type ) . add ( listener ) ; } } } @ SuppressWarnings ( "unchecked" ) final List < ListenerInstancePair < T > > resolvedListeners = List . class . cast ( this . cachedListeners . get ( event . getClass ( ) ) ) ; for ( final ListenerInstancePair < T > listener : resolvedListeners ) { listener . handleEvent ( event , null ) ; } }
Handle an event .