class FeatureValidator {

  void validateOptionIdsForUpdate(OptionCollection existing, OptionCollection update) {

    if (update.getItemsCount() == 0) {
      // no options sent in update, skip
      return;
    }

    final Set<String> firstSet =
        existing.getItemsList().stream().map(FeatureOption::getId).collect(Collectors.toSet());
    final Set<String> secondSet =
        update.getItemsList().stream().map(FeatureOption::getId).collect(Collectors.toSet());

    if (!firstSet.equals(secondSet)) {
      throw new ServiceException(
          Problem.clientProblem("option_ids_mismatch", "option ids must be the same",
              422));
    }
  }

}