Class AbstractCatchingFuture<V,X extends Throwable,F,T>
java.lang.Object
com.google.common.util.concurrent.internal.InternalFutureFailureAccess
com.google.common.util.concurrent.AbstractFuture<V>
com.google.common.util.concurrent.GwtFluentFutureCatchingSpecialization<V>
com.google.common.util.concurrent.FluentFuture<V>
com.google.common.util.concurrent.FluentFuture.TrustedFuture<V>
com.google.common.util.concurrent.AbstractCatchingFuture<V,X,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*
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
AnAbstractCatchingFuture
that delegates to anAsyncFunction
andAbstractFuture.setFuture(ListenableFuture)
.private static final class
AbstractCatchingFuture.CatchingFuture<V,
X extends Throwable> Nested classes/interfaces inherited from class com.google.common.util.concurrent.FluentFuture
FluentFuture.TrustedFuture<V>
Nested classes/interfaces inherited from class com.google.common.util.concurrent.AbstractFuture
AbstractFuture.Trusted<V>
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) F
(package private) ListenableFuture
<? extends V> Fields inherited from class com.google.common.util.concurrent.AbstractFuture
GENERATE_CANCELLATION_CAUSES, log
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractCatchingFuture
(ListenableFuture<? extends V> inputFuture, Class<X> exceptionType, F fallback) -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Callback method that is called exactly once after the future is completed.(package private) static <V,
X extends Throwable>
ListenableFuture<V> create
(ListenableFuture<? extends V> input, Class<X> exceptionType, Function<? super X, ? extends V> fallback, Executor executor) (package private) static <X extends Throwable,
V>
ListenableFuture<V> createAsync
(ListenableFuture<? extends V> input, Class<X> exceptionType, AsyncFunction<? super X, ? extends V> fallback, Executor executor) (package private) abstract T
doFallback
(F fallback, X throwable) Template method for subtypes to actually run the fallback.protected String
Provide a human-readable explanation of why this future has not yet completed.final void
run()
(package private) abstract void
Template method for subtypes to actually set the result.Methods inherited from class com.google.common.util.concurrent.FluentFuture.TrustedFuture
addListener, cancel, get, get, isCancelled, isDone
Methods inherited from class com.google.common.util.concurrent.FluentFuture
addCallback, catching, catchingAsync, from, from, transform, transformAsync, withTimeout, withTimeout
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
interruptTask, maybePropagateCancellationTo, set, setException, setFuture, toString, tryInternalFastPathGetFailure, wasInterrupted
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Field Details
-
inputFuture
-
exceptionType
-
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() -
pendingToString
Description copied from class:AbstractFuture
Provide a human-readable explanation of why this future has not yet completed.- Overrides:
pendingToString
in classAbstractFuture<V>
- Returns:
- null if an explanation cannot be provided (e.g. because the future is done).
-
doFallback
Template method for subtypes to actually run the fallback.- Throws:
Exception
-
setResult
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 classAbstractFuture<V>
-