public void callCallbacks ( Event event , CallbackType type ) throws CancelledException , AsyncException { String trigger = event . name ; if ( type == CallbackType . LEAVE_STATE ) trigger = event . src ; else if ( type == CallbackType . ENTER_STATE ) trigger = event . dst ; Callback [ ] callbacks = new Callback [ ] { this . callbacks . get ( new CallbackKey ( trigger , type ) ) , //Primary this . callbacks . get ( new CallbackKey ( "" , type ) ) , //General } ; for ( Callback callback : callbacks ) { if ( callback != null ) { callback . run ( event ) ; if ( type == CallbackType . LEAVE_STATE ) { if ( event . cancelled ) { transition = null ; throw new CancelledException ( event . error ) ; } else if ( event . async ) { throw new AsyncException ( event . error ) ; } } else if ( type == CallbackType . BEFORE_EVENT ) { if ( event . cancelled ) { throw new CancelledException ( event . error ) ; } } } } }
Calls the callbacks of type type ; first the named then the general version .