public static < T1 , T2 , R1 , R2 , R > CompletableFuture < R > forEach3 ( CompletableFuture < ? extends T1 > value1 , Function < ? super T1 , ? extends CompletableFuture < R1 > > value2 , BiFunction < ? super T1 , ? super R1 , ? extends CompletableFuture < R2 > > value3 , Function3 < ? super T1 , ? super R1 , ? super R2 , ? extends R > yieldingFunction ) { return value1 . thenCompose ( in -> { CompletableFuture < R1 > a = value2 . apply ( in ) ; return a . thenCompose ( ina -> { CompletableFuture < R2 > b = value3 . apply ( in , ina ) ; return b . thenApply ( in2 -> yieldingFunction . apply ( in , ina , in2 ) ) ; } ) ; } ) ; }
Perform a For Comprehension over a CompletableFuture accepting 2 generating function . This results in a three level nested internal iteration over the provided CompletableFutures .