class RequestStageContainer {

  public State getProjectedState(String host, String component) {
    RoleCommand lastCommand = null;

    ListIterator<Stage> iterator = stages.listIterator(stages.size());
    while (lastCommand == null && iterator.hasPrevious()) {
      Stage stage = iterator.previous();

      Map<String, Map<String, HostRoleCommand>> stageCommands = stage.getHostRoleCommands();
      if (stageCommands != null) {
        Map<String, HostRoleCommand> hostCommands = stageCommands.get(host);
        if (hostCommands != null) {
          HostRoleCommand roleCommand = hostCommands.get(component);
          if (roleCommand != null && roleCommand.getRoleCommand() != RoleCommand.SERVICE_CHECK) {
            lastCommand = roleCommand.getRoleCommand();
          }
        }
      }
    }

    State resultingState = null;
    if (lastCommand != null) {
      switch(lastCommand) {
        case INSTALL:
        case STOP:
          resultingState = State.INSTALLED;
          break;
        case START:
          resultingState = State.STARTED;
          break;
        case UNINSTALL:
          resultingState = State.INIT;
          break;
        default:
          resultingState = State.UNKNOWN;
      }
    }
    return resultingState;
  }

  public  RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager);
  public  RequestStageContainer(Long id, List<Stage> stages, RequestFactory factory, ActionManager manager,
                               ExecuteActionRequest actionRequest);

}