private boolean checkEventsControllers ( EventModel event ) { List < CompletableFuture < Boolean >> collect = eventsControllers . stream ( ) . map ( controller -> submit ( ( ) -> controller . controlEventDispatcher ( event ) ) . thenApply ( result -> { if ( ! result ) debug ( "Event: " + event + " is canceled by " + controller . getID ( ) ) ; return result ; } ) ) . collect ( Collectors . toList ( ) ) ; try { collect = timeOut ( collect , 1000 ) ; } catch ( InterruptedException e ) { debug ( "interrupted" ) ; } return collect . stream ( ) . map ( future -> { try { return future . get ( ) ; } catch ( InterruptedException | ExecutionException e ) { return null ; } } ) . filter ( Objects :: nonNull ) . noneMatch ( bool -> ! bool ) ; }
Checks whether to dispatch an event