shadows/framework/src/main/java/org/robolectric/shadows/ShadowMediaPlayer.java
private void checkStateException(String method, EnumSet<State> allowedStates) {
    if (!allowedStates.contains(state)) {
      String msg = "Can't call " + method + " from state " + state;
      switch (invalidStateBehavior) {
      case SILENT:
        break;
      case EMULATE:
        throw new IllegalStateException(msg);
      case ASSERT:
        throw new AssertionError(msg);
      }
    }
  }
private void checkStateException(String method, EnumSet<State> allowedStates) {
    if (!allowedStates.contains(state)) {
      String msg = "Can't call " + method + " from state " + state;
      switch (invalidStateBehavior) {
      case SILENT:
        break;
      case EMULATE:
        throw new IllegalStateException(msg);
      case ASSERT:
        throw new AssertionError(msg);
      }
    }
  }
private void checkStateException ( String method , EnumSet < State > allowedStates ) { if ( ! allowedStates . contains ( state ) ) { String msg = "Can't call " + method + " from state " + state ; switch ( invalidStateBehavior ) { case SILENT : break ; case EMULATE : throw new IllegalStateException ( msg ) ; case ASSERT : throw new AssertionError ( msg ) ; } } }
Checks states for methods that synchronously throw an exception when
invoked in an illegal state. This method will likewise throw an
{@link IllegalArgumentException} if it determines that the method has been
invoked from a disallowed state, or else it will generate an assertion if
{@link #setAssertOnError assertOnError} is set.

@param method
the name of the method being tested.
@param allowedStates
the states that this method is allowed to be called from.
@see #setAssertOnError
@see #checkStateLog(String, EnumSet)
@see #checkStateError(String, EnumSet)
Checks states for methods that synchronously throw an exception when invoked in an illegal state . This method will likewise throw an { @link IllegalArgumentException } if it determines that the method has been invoked from a disallowed state or else it will generate an assertion if { @link #setAssertOnError assertOnError } is set .