public void awaitState ( State state , Consumer < State > listener ) { if ( this . state == state ) { listener . accept ( this . state ) ; } else { addStateChangeListener ( new Consumer < State > ( ) { @ Override public void accept ( State state ) { listener . accept ( state ) ; removeStateChangeListener ( this ) ; } } ) ; } }
Awaits a state change .