spotify / completable-futures

Utilities for working with futures in Java 8
Apache License 2.0
393 stars 51 forks source link

Add allAsMap #70

Closed sashahe closed 4 years ago

sashahe commented 4 years ago

If you want to join a map of key and value-futures, each of uniform type, use allAsMap. This returns a future which completes to a map of all key values of its inputs:

  Map<String, CompletableFuture<String>> futures = new HashMap() {{
    put("key", completedFuture("value"));
  }};
  CompletableFuture<Map<String, String>> joined = CompletableFutures.allAsMap(futures);
codecov[bot] commented 4 years ago

Codecov Report

Merging #70 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##              master       #70   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity        80        84    +4     
===========================================
  Files              7         7           
  Lines            212       222   +10     
  Branches          14        16    +2     
===========================================
+ Hits             212       222   +10     
Impacted Files Coverage Δ Complexity Δ
...main/java/com/spotify/futures/CombinedFutures.java 100.00% <100.00%> (ø) 7.00 <7.00> (ø)
...n/java/com/spotify/futures/CompletableFutures.java 100.00% <100.00%> (ø) 49.00 <8.00> (+4.00)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 25bbd6e...28030c2. Read the comment docs.

sashahe commented 4 years ago

I agree, I missed that. I added a description to the README