Class AbstractCatchingFuture<V,X extends Throwable,F,T>

All Implemented Interfaces:
AbstractFuture.Trusted<V>, ListenableFuture<V>, Runnable, Future<V>
Direct Known Subclasses:
AbstractCatchingFuture.AsyncCatchingFuture, AbstractCatchingFuture.CatchingFuture

abstract class AbstractCatchingFuture<V,X extends Throwable,F,T> extends FluentFuture.TrustedFuture<V> implements Runnable
Implementations of Futures.catching*.
  • Field Details

    • inputFuture

      @CheckForNull ListenableFuture<? extends V> inputFuture
    • exceptionType

      @CheckForNull Class<X extends Throwable> exceptionType
    • fallback

      @CheckForNull F fallback
  • Constructor Details

    • AbstractCatchingFuture

      AbstractCatchingFuture(ListenableFuture<? extends V> inputFuture, Class<X> exceptionType, F fallback)
  • Method Details

    • create

      static <V, X extends Throwable> ListenableFuture<V> create(ListenableFuture<? extends V> input, Class<X> exceptionType, Function<? super X,? extends V> fallback, Executor executor)
    • createAsync

      static <X extends Throwable, V> ListenableFuture<V> createAsync(ListenableFuture<? extends V> input, Class<X> exceptionType, AsyncFunction<? super X,? extends V> fallback, Executor executor)
    • run

      public final void run()
      Specified by:
      run in interface Runnable
    • pendingToString

      @CheckForNull protected String pendingToString()
      Description copied from class: AbstractFuture
      Provide a human-readable explanation of why this future has not yet completed.
      Overrides:
      pendingToString in class AbstractFuture<V>
      Returns:
      null if an explanation cannot be provided (e.g. because the future is done).
    • doFallback

      abstract T doFallback(F fallback, X throwable) throws Exception
      Template method for subtypes to actually run the fallback.
      Throws:
      Exception
    • setResult

      abstract void setResult(T result)
      Template method for subtypes to actually set the result.
    • afterDone

      protected final void afterDone()
      Description copied from class: AbstractFuture
      Callback method that is called exactly once after the future is completed.

      If AbstractFuture.interruptTask() is also run during completion, AbstractFuture.afterDone() runs after it.

      The default implementation of this method in AbstractFuture does nothing. This is intended for very lightweight cleanup work, for example, timing statistics or clearing fields. If your task does anything heavier consider, just using a listener with an executor.

      Overrides:
      afterDone in class AbstractFuture<V>