Class AbstractCatchingFuture<V,​X extends java.lang.Throwable,​F,​T>

    • Field Detail

      • exceptionType

        @Nullable
        java.lang.Class<X extends java.lang.Throwable> exceptionType
      • fallback

        @Nullable
        F fallback
    • Constructor Detail

      • AbstractCatchingFuture

        AbstractCatchingFuture​(ListenableFuture<? extends V> inputFuture,
                               java.lang.Class<X> exceptionType,
                               F fallback)
    • Method Detail

      • create

        static <X extends java.lang.Throwable,​V> ListenableFuture<V> create​(ListenableFuture<? extends V> input,
                                                                                  java.lang.Class<X> exceptionType,
                                                                                  Function<? super X,​? extends V> fallback)
      • create

        static <V,​X extends java.lang.Throwable> ListenableFuture<V> create​(ListenableFuture<? extends V> input,
                                                                                  java.lang.Class<X> exceptionType,
                                                                                  Function<? super X,​? extends V> fallback,
                                                                                  java.util.concurrent.Executor executor)
      • create

        static <X extends java.lang.Throwable,​V> ListenableFuture<V> create​(ListenableFuture<? extends V> input,
                                                                                  java.lang.Class<X> exceptionType,
                                                                                  AsyncFunction<? super X,​? extends V> fallback,
                                                                                  java.util.concurrent.Executor executor)
      • run

        public final void run()
        Specified by:
        run in interface java.lang.Runnable
      • doFallback

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

        abstract void setResult​(@Nullable
                                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>