class UpgradePack {

  public List<Grouping> getGroups(Direction direction) {
    List<Grouping> list = new ArrayList<>();
    if (direction.isUpgrade()) {
      list = groups;
    } else {
      switch (type) {
        case NON_ROLLING:
          list = getDowngradeGroupsForNonrolling();
          break;
        case HOST_ORDERED:
        case ROLLING:
        default:
          list = getDowngradeGroupsForRolling();
          break;
      }
    }

    List<Grouping> checked = new ArrayList<>();
    for (Grouping group : list) {
      if (null == group.intendedDirection || direction == group.intendedDirection) {
        checked.add(group);
      }

    }

    return checked;
  }

}