public static CompletionStage < Void > allOf ( CompletionStage < ? > ... stages ) { AggregateCompletionStage < Void > aggregateCompletionStage = null ; for ( CompletionStage < ? > stage : stages ) { if ( ! isCompletedSuccessfully ( stage ) ) { if ( aggregateCompletionStage == null ) { aggregateCompletionStage = CompletionStages . aggregateCompletionStage ( ) ; } aggregateCompletionStage . dependsOn ( stage ) ; } } return aggregateCompletionStage != null ? aggregateCompletionStage . freeze ( ) : CompletableFutures . completedNull ( ) ; }
Returns a CompletionStage that completes when all of the provided stages complete either normally or via exception . If one or more states complete exceptionally the returned CompletionStage will complete with the exception of one of these . If no CompletionStages are provided returns a CompletionStage completed with the value null .