Source:
public List<EntryUpdateTime> getUserEntries(@ApiParam(hidden = true) @Parameter(hidden = true, name = "user", in = ParameterIn.HEADER) @Auth User authUser, @Parameter(name = "count", description = "Maximum number of entries to return", in = ParameterIn.QUERY) @QueryParam("count") Integer count, @Parameter(name = "filter", description = "Filter paths with matching text", in = ParameterIn.QUERY) @QueryParam("filter") String filter) { final List<EntryUpdateTime> entryUpdateTimes = new ArrayList<>(); final User fetchedUser = this.userDAO.findById(authUser.getId()); Set<Entry> entries = fetchedUser.getEntries(); entries.forEach(entry -> { Timestamp timestamp = entry.getDbUpdateDate(); Set<Version> versions = entry.getWorkflowVersions(); Optional<Version> mostRecentTag = versions.stream().max(Comparator.comparing(Version::getDbUpdateDate)); if (mostRecentTag.isPresent() && timestamp.before(mostRecentTag.get().getDbUpdateDate())) { timestamp = mostRecentTag.get().getDbUpdateDate(); } List<String> pathElements = Arrays.asList(entry.getEntryPath().split("/")); String prettyPath = pathElements.subList(1, pathElements.size()).stream().collect(Collectors.joining("/")); entryUpdateTimes.add(new EntryUpdateTime(entry.getEntryPath(), prettyPath, entry.getEntryType(), timestamp)); }); List<EntryUpdateTime> sortedEntries = entryUpdateTimes .stream() .filter((EntryUpdateTime entryUpdateTime) -> filter == null || filter.isBlank() || entryUpdateTime.getPath().contains(filter)) .sorted(Comparator.comparing(EntryUpdateTime::getLastUpdateDate, Comparator.nullsLast(Comparator.reverseOrder()))) .collect(Collectors.toList()); if (count != null) { return sortedEntries.subList(0, Math.min(count, sortedEntries.size())); } return sortedEntries; }

Target:
public List<EntryUpdateTime> getUserEntries(@ApiParam(hidden = true) @Parameter(hidden = true, name = "user", in = ParameterIn.HEADER) @Auth User authUser, @Parameter(name = "count", description = "Maximum number of entries to return", in = ParameterIn.QUERY) @QueryParam("count") Integer count, @Parameter(name = "filter", description = "Filter paths with matching text", in = ParameterIn.QUERY) @QueryParam("filter") String filter) { final List<EntryUpdateTime> entryUpdateTimes = new ArrayList<>(); final User fetchedUser = this.userDAO.findById(authUser.getId()); Set<Entry> entries = fetchedUser.getEntries(); entries.forEach(entry -> { Timestamp timestamp = entry.getDbUpdateDate(); Set<Version> versions = entry.getWorkflowVersions(); Optional<Version> mostRecentTag = versions.stream().max(Comparator.comparing(Version::getDbUpdateDate)); if (mostRecentTag.isPresent() && timestamp.before(mostRecentTag.get().getDbUpdateDate())) { timestamp = mostRecentTag.get().getDbUpdateDate(); } List<String> pathElements = Arrays.asList(entry.getEntryPath().split("/")); String prettyPath = String.join("/", pathElements.subList(1, pathElements.size())); entryUpdateTimes.add(new EntryUpdateTime(entry.getEntryPath(), prettyPath, entry.getEntryType(), timestamp)); }); List<EntryUpdateTime> sortedEntries = entryUpdateTimes .stream() .filter((EntryUpdateTime entryUpdateTime) -> filter == null || filter.isBlank() || entryUpdateTime.getPath().contains(filter)) .sorted(Comparator.comparing(EntryUpdateTime::getLastUpdateDate, Comparator.nullsLast(Comparator.reverseOrder()))) .collect(Collectors.toList()); if (count != null) { return sortedEntries.subList(0, Math.min(count, sortedEntries.size())); } return sortedEntries; }