private static Optional<Delta> calculateDifferencesAndReturnLowestVisible( List<SuggestionGroup> aGroups) { return aGroups.stream() // Fetch the top deltas per recommender .flatMap(group -> group.getTopDeltas().values().stream()) // ... sort them in ascending order (smallest delta first) .sorted(Comparator.comparingDouble(Delta::getDelta)) // ... and return the smallest delta (if there is one) .findFirst(); } }
private static Optional<Delta> calculateDifferencesAndReturnLowestVisible( List<SuggestionGroup> aGroups) { return aGroups.stream() // Fetch the top deltas per recommender .flatMap(group -> group.getTopDeltas().values().stream()) // ... sort them in ascending order (smallest delta first) .sorted(Comparator.comparingDouble(Delta::getDelta)) // ... and return the smallest delta (if there is one) .findFirst(); } }