public static boolean isValidDesiredStateTransition(State startState, State desiredState) {
    switch(desiredState) {
      case INSTALLED:
        if (startState == State.INIT
            || startState == State.UNINSTALLED
            || startState == State.INSTALLED
            || startState == State.STARTED
            || startState == State.STOPPING) {
          return true;
        }
        break;
      case STARTED:
        if (startState == State.INSTALLED
            || startState == State.STARTED) {
          return true;
        }
        break;
    }
    return false;
  }
Utility method to determine whether or not the given desired state is valid for the given starting state.

@param startState    the starting state
@param desiredState  the desired state

@return true iff the given desired state is valid for the given starting state
ambari-server/src/main/java/org/apache/ambari/server/state/State.java