@GwtCompatible abstract class AbstractCatchingFuture<V,X extends java.lang.Throwable,F,T> extends AbstractFuture.TrustedFuture<V> implements java.lang.Runnable
Futures.catching*
.Modifier and Type | Class and Description |
---|---|
private static class |
AbstractCatchingFuture.AsyncCatchingFuture<V,X extends java.lang.Throwable>
An
AbstractCatchingFuture that delegates to an AsyncFunction and
AbstractFuture.setFuture(ListenableFuture) . |
private static class |
AbstractCatchingFuture.CatchingFuture<V,X extends java.lang.Throwable>
|
AbstractFuture.TrustedFuture<V>
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.Class<X> |
exceptionType |
(package private) F |
fallback |
(package private) ListenableFuture<? extends V> |
inputFuture |
Constructor and Description |
---|
AbstractCatchingFuture(ListenableFuture<? extends V> inputFuture,
java.lang.Class<X> exceptionType,
F fallback) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterDone()
Callback method that is called exactly once after the future is completed.
|
(package private) static <X extends java.lang.Throwable,V> |
create(ListenableFuture<? extends V> input,
java.lang.Class<X> exceptionType,
AsyncFunction<? super X,? extends V> fallback) |
(package private) static <X extends java.lang.Throwable,V> |
create(ListenableFuture<? extends V> input,
java.lang.Class<X> exceptionType,
AsyncFunction<? super X,? extends V> fallback,
java.util.concurrent.Executor executor) |
(package private) static <X extends java.lang.Throwable,V> |
create(ListenableFuture<? extends V> input,
java.lang.Class<X> exceptionType,
Function<? super X,? extends V> fallback) |
(package private) static <V,X extends java.lang.Throwable> |
create(ListenableFuture<? extends V> input,
java.lang.Class<X> exceptionType,
Function<? super X,? extends V> fallback,
java.util.concurrent.Executor executor) |
(package private) abstract T |
doFallback(F fallback,
X throwable)
Template method for subtypes to actually run the fallback.
|
void |
run() |
(package private) abstract void |
setResult(T result)
Template method for subtypes to actually set the result.
|
addListener, cancel, get, get, isCancelled, isDone
interruptTask, maybePropagateCancellation, set, setException, setFuture, trustedGetException, wasInterrupted
@Nullable ListenableFuture<? extends V> inputFuture
@Nullable java.lang.Class<X extends java.lang.Throwable> exceptionType
@Nullable F fallback
AbstractCatchingFuture(ListenableFuture<? extends V> inputFuture, java.lang.Class<X> exceptionType, F fallback)
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)
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)
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)
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)
public final void run()
run
in interface java.lang.Runnable
@Nullable abstract T doFallback(F fallback, X throwable) throws java.lang.Exception
java.lang.Exception
abstract void setResult(@Nullable T result)
protected final void afterDone()
AbstractFuture
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.
afterDone
in class AbstractFuture<V>