Class AbstractCatchingFuture<V,X extends java.lang.Throwable,F,T>
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractFuture<V>
-
- com.google.common.util.concurrent.AbstractFuture.TrustedFuture<V>
-
- com.google.common.util.concurrent.AbstractCatchingFuture<V,X,F,T>
-
- All Implemented Interfaces:
ListenableFuture<V>
,java.lang.Runnable
,java.util.concurrent.Future<V>
- Direct Known Subclasses:
AbstractCatchingFuture.AsyncCatchingFuture
,AbstractCatchingFuture.CatchingFuture
@GwtCompatible abstract class AbstractCatchingFuture<V,X extends java.lang.Throwable,F,T> extends AbstractFuture.TrustedFuture<V> implements java.lang.Runnable
Implementations ofFutures.catching*
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AbstractCatchingFuture.AsyncCatchingFuture<V,X extends java.lang.Throwable>
AnAbstractCatchingFuture
that delegates to anAsyncFunction
andAbstractFuture.setFuture(ListenableFuture)
.private static class
AbstractCatchingFuture.CatchingFuture<V,X extends java.lang.Throwable>
-
Nested classes/interfaces inherited from class com.google.common.util.concurrent.AbstractFuture
AbstractFuture.TrustedFuture<V>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.Class<X>
exceptionType
(package private) F
fallback
(package private) ListenableFuture<? extends V>
inputFuture
-
Constructor Summary
Constructors Constructor Description AbstractCatchingFuture(ListenableFuture<? extends V> inputFuture, java.lang.Class<X> exceptionType, F fallback)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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>
ListenableFuture<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>
ListenableFuture<V>create(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, Function<? super X,? extends V> fallback, java.util.concurrent.Executor executor)
(package private) 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)
(package private) 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)
(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.-
Methods inherited from class com.google.common.util.concurrent.AbstractFuture.TrustedFuture
addListener, cancel, get, get, isCancelled, isDone
-
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
interruptTask, maybePropagateCancellation, set, setException, setFuture, trustedGetException, wasInterrupted
-
-
-
-
Field Detail
-
inputFuture
@Nullable ListenableFuture<? extends V> inputFuture
-
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)
-
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 interfacejava.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 classAbstractFuture<V>
-
-