abstract class AbstractCatchingFuture<V,X extends java.lang.Throwable,F,T> extends FluentFuture.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>
|
FluentFuture.TrustedFuture<V>
AbstractFuture.Trusted<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,
java.util.concurrent.Executor executor) |
(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.
|
protected java.lang.String |
pendingToString()
Provide a human-readable explanation of why this future has not yet completed.
|
void |
run() |
(package private) abstract void |
setResult(T result)
Template method for subtypes to actually set the result.
|
addListener, cancel, get, get, isCancelled, isDone
addCallback, catching, catchingAsync, from, from, transform, transformAsync, withTimeout, withTimeout
interruptTask, maybePropagateCancellationTo, set, setException, setFuture, toString, tryInternalFastPathGetFailure, wasInterrupted
ListenableFuture<? extends V> inputFuture
java.lang.Class<X extends java.lang.Throwable> exceptionType
F fallback
AbstractCatchingFuture(ListenableFuture<? extends V> inputFuture, java.lang.Class<X> exceptionType, F 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, java.util.concurrent.Executor executor)
public final void run()
run
in interface java.lang.Runnable
protected java.lang.String pendingToString()
AbstractFuture
pendingToString
in class AbstractFuture<V>
abstract T doFallback(F fallback, X throwable) throws java.lang.Exception
java.lang.Exception
abstract void setResult(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>