How to divide 1 completablefuture to many completablefuture in stream?
For example I have such methods: public CompletableFuture<Page> getPage(int i) { ... } public CompletableFuture<Document> getDocument(int i) { ... } public CompletableFuture<Void> parseLinks(Document doc) { ... } And my flow: List<CompletableFuture> list = IntStream .range(0, 10) .mapToObj(i -> getPage(i)) // I want method like this: .thenApplyAndSplit(CompletableFuture<Page> page -> { List<CompletableFuture<Document>> docs = page.getDocsId() .stream() .map(i -> getDocument(i)) .collect(Collectors.toList()); return docs; }) .map(CompletableFuture<Document> future -> { return future.thenApply