thenApply
The CompletableFuture method that transforms a stage's result once it is available, producing a new stage.
In more detail
It is the asynchronous equivalent of map. If the earlier stage failed, the transformation is skipped and the failure passes on.
Example
.thenApply(String::toUpperCase)Related terms
- CompletableFuture — A Future that can be completed later and chained, letting you describe asynchronous steps such as transform, combine and recover without nesting callbacks.
- thenCombine — The CompletableFuture method that waits for two independent stages and combines their results with a function.
Taught in
- Async With CompletableFuture — Modern Java: Virtual Threads & High-Throughput Services