Skip to content

Commit

Permalink
fix(#7): Исправления кода проверок идентификаторов форм по результатам
Browse files Browse the repository at this point in the history
ревью

- Код стал быстрее и понятнее
  • Loading branch information
nikolay-martynov committed Aug 10, 2022
1 parent b39e293 commit 7c7e0a8
Showing 1 changed file with 4 additions and 9 deletions.
Expand Up @@ -132,8 +132,8 @@ public Map<FormItem, String> validate(Form form)
.entrySet()
.stream()
.filter(idAndItems -> idAndItems.getValue().size() > 1);
Stream<Map.Entry<FormItem, String>> duplicateIdIssues = duplicateIdAndItems.flatMap(idAndItems -> idAndItems
.getValue()
Stream<Map.Entry<FormItem, String>> duplicateIdIssues =
duplicateIdAndItems.flatMap(idAndItems -> idAndItems.getValue()
.stream()
.skip(1)
.map(item -> new AbstractMap.SimpleEntry<>(item, MessageFormat
Expand Down Expand Up @@ -180,13 +180,8 @@ private Optional<Integer> calculateNewIdFor(FormItem item)
return Optional.of(-1);
}
IBmObject topObject = item.bmGetTopObject();
if (!(topObject instanceof Form))
{
return Optional.empty();
}
Form form = (Form)item.bmGetTopObject();
int newValue = formIdentifierService.getNextItemId(form);
return Optional.of(newValue);
return topObject instanceof Form ? Optional.of(formIdentifierService.getNextItemId((Form)topObject))
: Optional.empty();
}

}

0 comments on commit 7c7e0a8

Please sign in to comment.