How to turn a List<Item> to a Map<Item, completeablefuture<xyz>>
问题 I have an async method with a completeablefuture result: public CompletableFuture<DogLater> asyncDogLater(String dogName){} I have a list of dogs: List<Dog> dogs; Now, I want to create a map from the dog's name to the Completeablefuture: Map<String, CompletableFuture<DogLater>> map; After checking this and this I was trying to do so: Map<String, CompletableFuture<DogLater>> completableFutures = dogs.stream() .collect( Collectors.toMap(Dog::getName, asyncDogLater(Dog::getName ))); But the