Skip to content
Discussion options

You must be logged in to vote

You can for example use thenApply on the CompletableFuture, which is similar to map on a stream.

return CompletableFuture.supplyAsync(() -> reviewsService.reviewsForShows(new ArrayList<>(keys))).thenApply(r -> {
            Map<Integer, List<Review>> filtered = new HashMap<>();

            r.keySet().forEach(key -> {
                filtered.put(key, r.get(key).stream().filter(review -> review.getStarScore() > 3).collect(Collectors.toList()));
            }) ;

            return filtered;
        });

There are probably nicer ways to write the same code, but this gives an idea of what you can do.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by peterbierman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants