Class CollectFutureBuilder<T>

java.lang.Object
com.arpnetworking.utility.CollectFutureBuilder<T>
Type Parameters:
T - Return future type

public final class CollectFutureBuilder<T> extends Object
Collects futures and provides them in a combined promise.
Author:
Brandon Arp (brandon dot arp at inscopemetrics dot com)
  • Constructor Details

    • CollectFutureBuilder

      public CollectFutureBuilder()
  • Method Details

    • map

      public CollectFutureBuilder<T> map(scala.Function0<T> callback)
      Method to create a <T> from the completed Futures.
      Parameters:
      callback - Callback function
      Returns:
      this builder
    • addFuture

      public CollectFutureBuilder<T> addFuture(scala.concurrent.Future<?> future)
      Registers a Future in the collection. A future must be registered in order to be waited on.
      Parameters:
      future - Future to register
      Returns:
      this builder
    • setFutures

      public CollectFutureBuilder<T> setFutures(List<scala.concurrent.Future<?>> futures)
      Sets the list of Futures to wait on.
      Parameters:
      futures - The list of futures
      Returns:
      this builder
    • build

      public scala.concurrent.Future<T> build(scala.concurrent.ExecutionContext context)
      Builds the final future.
      Parameters:
      context - context to execute the futures on
      Returns:
      the new future