java multi nested CompletionStage equivalent to "flatMap"?
<p>So considering I have the following example:</p>

<pre><code>CompletionStage&lt;String&gt; tokenFuture = getToken();

CompletionStage&lt;CompletionStage&lt;CompletionStage&lt;CompletionStage&lt;Boolean&gt;&gt;&gt;&gt; result = tokenFuture.thenApply(token -&gt; {

    WSRequest request = ws.url(url).setHeader("Authorization", "Bearer " + token);

    CompletionStage&lt;WSResponse&gt; response = request.post(json);

    return response.thenApply(r -&gt; {
        if (r.getStatus() == 201) {
            return CompletableFuture.supplyAsync(() -&gt; CompletableFuture.supplyAsync(() -&gt; true));
        } else {
            return getToken().thenApply(t -&gt; {
                WSRequest req = ws.url(url).setHeader("Authorization", "Bearer " + t);
                return req.post(json).thenApply(b -&gt; b.getStatus() == 201);
            });
        }
    });

});
</code></pre>

<p>My problem is with the whole <code>CompletionStage&lt;CompletionStage&lt;CompletionStage&lt;CompletionStage&lt;Boolean&gt;&gt;&gt;&gt;</code> multi nested future type. Is it possible to reduce it to just <code>CompletionStage&lt;Boolean&gt;</code> by using something like <code>flatMap</code> in Scala or is there another way to do this?</p>