Class FutureUtils.ConjunctFuture<T>

  • All Implemented Interfaces:
    CompletionStage<T>, Future<T>
    Enclosing class:
    FutureUtils

    public abstract static class FutureUtils.ConjunctFuture<T>
    extends CompletableFuture<T>
    A future that is complete once multiple other futures completed. The futures are not necessarily of the same type. The ConjunctFuture fails (completes exceptionally) once one of the Futures in the conjunction fails.

    The advantage of using the ConjunctFuture over chaining all the futures (such as via CompletableFuture.thenCombine(CompletionStage, BiFunction)) is that ConjunctFuture also tracks how many of the Futures are already complete.

    • Constructor Detail

      • ConjunctFuture

        public ConjunctFuture()
    • Method Detail

      • getNumFuturesTotal

        public abstract int getNumFuturesTotal()
        Gets the total number of Futures in the conjunction.
        Returns:
        The total number of Futures in the conjunction.
      • getNumFuturesCompleted

        public abstract int getNumFuturesCompleted()
        Gets the number of Futures in the conjunction that are already complete.
        Returns:
        The number of Futures in the conjunction that are already complete