private static boolean isLegal(final State from, final State to) {
    if (from == null) {
      return to == State.INIT;
    }
    switch (from) {
    case PRE_INIT:
      switch (to) {
      case INIT:
        return true;
      default:
        return false;
      }
    case INIT:
      switch (to) {
      case RUNNING:
      case FAILED:
      case KILLED:
      case DONE:
        return true;
      default:
        return false;
      }
    case RUNNING:
      switch (to) {
      case CLOSE_REQUESTED:
      case SUSPEND_REQUESTED:
      case FAILED:
      case KILLED:
      case DONE:
        return true;
      default:
        return false;
      }
    case CLOSE_REQUESTED:
      switch (to) {
      case FAILED:
      case KILLED:
      case DONE:
        return true;
      default:
        return false;
      }
    case SUSPEND_REQUESTED:
      switch (to) {
      case FAILED:
      case KILLED:
      case SUSPENDED:
        return true;
      default:
        return false;
      }

    case FAILED:
    case DONE:
    case KILLED:
      return false;
    default:
      return false;
    }
  }
private static boolean isLegal ( final State from , final State to ) { if ( from == null ) { return to == State . INIT ; } switch ( from ) { case PRE_INIT : switch ( to ) { case INIT : return true ; default : return false ; } case INIT : switch ( to ) { case RUNNING : case FAILED : case KILLED : case DONE : return true ; default : return false ; } case RUNNING : switch ( to ) { case CLOSE_REQUESTED : case SUSPEND_REQUESTED : case FAILED : case KILLED : case DONE : return true ; default : return false ; } case CLOSE_REQUESTED : switch ( to ) { case FAILED : case KILLED : case DONE : return true ; default : return false ; } case SUSPEND_REQUESTED : switch ( to ) { case FAILED : case KILLED : case SUSPENDED : return true ; default : return false ; } case FAILED : case DONE : case KILLED : return false ; default : return false ; } }
@param from
@param to
@return true, if the state transition from state 'from' to state 'to' is legal.