Skip to content

Instantly share code, notes, and snippets.

@vichu
Created May 11, 2018 03:28
Show Gist options
  • Save vichu/35bab9e8b8b0073c008fc1588eba6dca to your computer and use it in GitHub Desktop.
Save vichu/35bab9e8b8b0073c008fc1588eba6dca to your computer and use it in GitHub Desktop.
compose and combine CompletableFutures
CompletableFuture<Map<String, Object>> myObjectCompletableFuture =
myCompletableFutureBigDecimal.thenCompose(bigDecimalValue ->
myCompletableFutureInt
.thenCombine(myCompletableFutureLong,
((integerValue, longValue) -> {
Map<String, Object> objectHashMap = new HashMap<>();
objectHashMap.put("IntegerValue", integerValue);
objectHashMap.put("LongValue", longValue);
objectHashMap.put("BigDecimalValue", bigDecimalValue);
return objectHashMap;
})));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment