question: 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 ) ) ; } }
target:  Checks that the machine is in the given state. Throws if it isn't.