public synchronized void transition(State newState) throws IllegalStateException {
  if (transitions.containsEntry(currentState,newState)) {
    currentState=newState;
  }
 else {
    throw new IllegalStateException(String.format(Locale.US,"Attempted invalid transition from %s to %s",currentState,newState));
  }
}

public synchronized void transition ( State newState ) throws IllegalStateException { if ( transitions . containsEntry ( currentState , newState ) ) { currentState = newState ; } else { throw new IllegalStateException ( String . format ( Locale . US , "Attempted invalid transition from %s to %s" , currentState , newState ) ) ; } }
transitions to a new state , provided that the required transition exists
