public synchronized void checkState(State requiredState) throws IllegalStateException {
  if (requiredState != currentState) {
    throw new IllegalStateException(String.format(Locale.US,"Expected state %s, but in state %s",requiredState,currentState));
  }
}

public synchronized void checkState ( State requiredState ) throws IllegalStateException { if ( requiredState != currentState ) { throw new IllegalStateException ( String . format ( Locale . US , "Expected state %s, but in state %s" , requiredState , currentState ) ) ; } }
checks that the machine is in the given state . throws if it isn ' t .
