title: How to transform CompletableFuture<Stream<T>> to Stream<CompletableFuture<T>>?
body: <p>That's it. Really could not find something even close. I want to implement the following chain of tasks </p>
  
  <pre><code>List&lt;Item&gt; items = Collections.singletonList(new Item("John Smith", "1997-2014"));
  
  Stream&lt;CompletableFuture&lt;List&lt;ScrappingResult&gt;&gt;&gt; scrappingFutures =
      items.stream().map(item -&gt;
          CompletableFuture.supplyAsync(() -&gt; new ScrappingTask(item).call()));
  
  Stream&lt;CompletableFuture&lt;ScrappingResult&gt;&gt; scrappingFuturesUnwrapped =
      scrappingFutures.map(resultsFuture -&gt; ???);
  
  Stream&lt;CompletableFuture&lt;TrimmingResult&gt;&gt; trimmingResults = scrappingFuturesUnwrapped.map(resultFuture -&gt;
      // thenCompose?
      resultFuture.thenCompose(result -&gt; {
          Path clipsDir = Paths.get("./"
              + result.getItem().getName()
              + "/" + result.getItem().getTimespan());
  
          AtomicInteger clipIdx = new AtomicInteger();
  
          return result.getVideo().getClips().stream()
              .map(clip -&gt; CompletableFuture.supplyAsync(() -&gt;
                  new TrimmingTask(
                      ffmpegPath,
                      result.getVideo().getVideoUrl(),
                      clip,
                      clipsDir.resolve("clip_" + clipIdx.incrementAndGet() + ".mp3")).call())
              );
      });
  );
  </code></pre>
  
  <p>The last line is not syntactically correct, but I hope conveys the idea. So, I want to do something like flatMap twice and get <code>
  Stream&lt;CompletableFuture&lt;TrimmingResult&gt;&gt;</code> at the end.</p>
  
  <p>How do I do that?</p>
  
  <p>Thanks.</p>