Class FluentFutures

java.lang.Object
org.opendaylight.yangtools.util.concurrent.FluentFutures

@Beta @NonNullByDefault public final class FluentFutures extends Object
Utility methods for working with FluentFutures. This class provides methods which should really live in Guava's, for example in Futures, as the implementations provided by Futures.immediateFuture(Object) and others already implement FluentFuture and so getting a FluentFuture is a matter of pure boiler-plate.

immediateBooleanFluentFuture(boolean), immediateBooleanFluentFuture(Boolean), immediateFalseFluentFuture(), immediateTrueFluentFuture() and immediateNullFluentFuture() provide low-cardinality constants, which are generally useful to reduce allocations.

Author:
Robert Varga
  • Method Details

    • immediateCancelledFluentFuture

      public static <T> FluentFuture<T> immediateCancelledFluentFuture()
      Return a FluentFuture which is immediately Future.cancel(boolean)led.
      Returns:
      An immediately-cancelled FluentFuture.
    • immediateFailedFluentFuture

      public static <T> FluentFuture<T> immediateFailedFluentFuture(Throwable cause)
      Return a FluentFuture which is immediately failed, reporting specified failure cause.
      Parameters:
      cause - failure cause
      Returns:
      An immediately-failed FluentFuture.
      Throws:
      NullPointerException - if cause is null
    • immediateFluentFuture

      public static <T> FluentFuture<T> immediateFluentFuture(T result)
      Return a FluentFuture which is immediately completed, reporting specified result.
      Parameters:
      result - result of the future
      Returns:
      An immediately-completed FluentFuture.
      Throws:
      NullPointerException - if result is null
    • immediateNullFluentFuture

      public static <@Nullable T> FluentFuture<T> immediateNullFluentFuture()
      Return a FluentFuture which is immediately completed with a null result.
      Returns:
      An immediately-completed FluentFuture.
    • immediateBooleanFluentFuture

      public static FluentFuture<Boolean> immediateBooleanFluentFuture(Boolean result)
      Return a FluentFuture which is immediately completed, reporting specified result.
      Parameters:
      result - boolean result
      Returns:
      An immediately-completed FluentFuture reporting specified result
      Throws:
      NullPointerException - if result is null
    • immediateBooleanFluentFuture

      public static FluentFuture<Boolean> immediateBooleanFluentFuture(boolean result)
      Return a FluentFuture which is immediately completed, reporting specified result.
      Parameters:
      result - boolean result
      Returns:
      An immediately-completed FluentFuture reporting specified result
    • immediateTrueFluentFuture

      public static FluentFuture<Boolean> immediateTrueFluentFuture()
      Return a FluentFuture which is immediately completed, reporting specified Boolean.TRUE.
      Returns:
      An immediately-completed FluentFuture reporting Boolean.TRUE
    • immediateFalseFluentFuture

      public static FluentFuture<Boolean> immediateFalseFluentFuture()
      Return a FluentFuture which is immediately completed, reporting specified Boolean.TRUE.
      Returns:
      An immediately-completed FluentFuture reporting Boolean.TRUE
    • submit

      public static <T> FluentFuture<T> submit(Callable<T> callable, Executor executor)
      Submit a Callable to specified Executor and return a FluentFuture that completes with the result of the Callable.
      Type Parameters:
      T - Callable return type
      Parameters:
      callable - The Callable to call
      executor - The Executor to use
      Throws:
      NullPointerException - if any argument is null