question: protected boolean compareAndSetState ( StateType oldState , StateType newState ) { if ( state . compareAndSet ( oldState , newState ) ) { afterStateChanged ( newState ) ; return true ; } else return false ; }
target:  Moves to a new state (newState) if the current state is equal to a given state (oldState)