I want to work with CompletableFuture and Stream at the same time. Something like transforming a CompletableFuture<Stream<String>> into a CompletableFuture<Stream<Team>>.
I have done something similar from CompletableFuture<String> to CompletableFuture<Integer>.
CompletableFuture<Stream<String>> getMostPopularTeamNames(int maxResults) {
CompletableFuture<Stream<String>> mostPopularTeamNames;
WorldCupSocialApi.getMostPopularTeamNames(1, maxResults, teams -> {
mostPopularTeamNames = CompletableFuture.supplyAsync(() -> teams.stream());
});
return mostPopularTeamNames;
}
I am trying to do something like:
CompletableFuture<Stream<Team>> cf = getMostPopularTeamNames(5).thenApply(s -> {
s.map(name -> new Team(name))
}
But I am not sure if I the s is going to be the String or the Stream, and if I can map it that way...