protected boolean compareAndSetState(StateType oldState,StateType newState){
  if (state.compareAndSet(oldState,newState)) {
    afterStateChanged(newState);
    return true;
  }
 else   return false;
}

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