- Set<String> set = new HashSet<>();
-
- for (PdpSubGroup subgrp : pdpSubgroups) {
- String pdpType = (subgrp == null ? null : subgrp.getPdpType());
-
- if (pdpType == null) {
- continue;
- }
-
- if (!set.add(pdpType)) {
- result.addResult(new ObjectValidationResult("subgroups", pdpType, ValidationStatus.INVALID,
- "duplicate subgroup"));
- }
+ // verify that the same subgroup doesn't appear more than once
+ List<String> pdpTypes = pdpSubgroups.stream().map(PdpSubGroup::getPdpType).collect(Collectors.toList());
+ if (pdpSubgroups.size() == new HashSet<>(pdpTypes).size()) {
+ return;