class ComponentCommandOrder {

  public boolean canExecute(String component, Command command, Collection<ComponentInstanceState> currentStates) {
    if (!dependencies.containsKey(command)) {
      return true;
    }
    List<ComponentState> required = new ArrayList<>();
    if (dependencies.get(command).containsKey(component)) {
      required.addAll(dependencies.get(command).get(component));
    }
    String prefix = rolePrefixMap.get(component);
    if (prefix != null && dependencies.get(command).containsKey(prefix)) {
      required.addAll(dependencies.get(command).get(prefix));
    }

    for (ComponentState stateToMatch : required) {
      for (ComponentInstanceState currState : currentStates) {
        log.debug("Checking schedule {} {} against dependency {} is {}",
            component, command, currState.getComponentName(), currState.getState());
        if (currState.getComponentName().equals(stateToMatch.componentName) ||
            (prefixRoleMap.containsKey(stateToMatch.componentName) &&
                prefixRoleMap.get(stateToMatch.componentName).contains(currState.getComponentName()))) {
          if (currState.getState() != stateToMatch.state) {
            if (stateToMatch.state == State.STARTED) {
              log.info("Cannot schedule {} {} as dependency {} is {}",
                  component, command, currState.getComponentName(), currState.getState());
              return false;
            } else {
              //state is INSTALLED
              if (currState.getState() != State.STARTING && currState.getState() != State.STARTED) {
                log.info("Cannot schedule {} {} as dependency {} is {}",
                    component, command, currState.getComponentName(), currState.getState());
                return false;
              }
            }
          }
        }
      }
    }
    return true;
  }

  public  ComponentCommandOrder();
  public  ComponentCommandOrder(List<CommandOrder> commandOrders,
      ConfTreeOperations resources);

}