javadoc.com.google.common.util.concurrent.AbstractCheckedFuture.html Maven / Gradle / Ivy
AbstractCheckedFuture (Guava: Google Core Libraries for Java 11.0.1 API)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
com.google.common.util.concurrent
Class AbstractCheckedFuture<V,X extends Exception>
java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.util.concurrent.ForwardingFuture<V>
com.google.common.util.concurrent.ForwardingListenableFuture<V>
com.google.common.util.concurrent.ForwardingListenableFuture.SimpleForwardingListenableFuture<V>
com.google.common.util.concurrent.AbstractCheckedFuture<V,X>
- All Implemented Interfaces:
- CheckedFuture<V,X>, ListenableFuture<V>, Future<V>
@Beta
public abstract class AbstractCheckedFuture<V,X extends Exception>
- extends ForwardingListenableFuture.SimpleForwardingListenableFuture<V>
- implements CheckedFuture<V,X>
A delegating wrapper around a ListenableFuture
that adds support for
the checkedGet()
and checkedGet(long, TimeUnit)
methods.
- Since:
- 1.0
- Author:
- Sven Mawson
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.google.common.util.concurrent.ForwardingListenableFuture |
---|
ForwardingListenableFuture.SimpleForwardingListenableFuture<V> |
Nested classes/interfaces inherited from class com.google.common.util.concurrent.ForwardingFuture |
---|
ForwardingFuture.SimpleForwardingFuture<V> |
Constructor Summary | |
---|---|
protected |
AbstractCheckedFuture(ListenableFuture<V> delegate)
Constructs an AbstractCheckedFuture that wraps a delegate. |
Method Summary | |
---|---|
V |
checkedGet()
Exception checking version of Future.get() that will translate
InterruptedException , CancellationException and
ExecutionException into application-specific exceptions. |
V |
checkedGet(long timeout,
TimeUnit unit)
Exception checking version of Future.get(long, TimeUnit) that will
translate InterruptedException , CancellationException and
ExecutionException into application-specific exceptions. |
protected abstract X |
mapException(Exception e)
Translates from an InterruptedException ,
CancellationException or ExecutionException thrown by
get to an exception of type X to be thrown by
checkedGet . |
Methods inherited from class com.google.common.util.concurrent.ForwardingListenableFuture.SimpleForwardingListenableFuture |
---|
delegate |
Methods inherited from class com.google.common.util.concurrent.ForwardingListenableFuture |
---|
addListener |
Methods inherited from class com.google.common.util.concurrent.ForwardingFuture |
---|
cancel, get, get, isCancelled, isDone |
Methods inherited from class com.google.common.collect.ForwardingObject |
---|
toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.google.common.util.concurrent.ListenableFuture |
---|
addListener |
Methods inherited from interface java.util.concurrent.Future |
---|
cancel, get, get, isCancelled, isDone |
Constructor Detail |
---|
AbstractCheckedFuture
protected AbstractCheckedFuture(ListenableFuture<V> delegate)
- Constructs an
AbstractCheckedFuture
that wraps a delegate.
Method Detail |
---|
mapException
protected abstract X mapException(Exception e)
- Translates from an
InterruptedException
,CancellationException
orExecutionException
thrown byget
to an exception of typeX
to be thrown bycheckedGet
. Subclasses must implement this method.If
e
is anInterruptedException
, the callingcheckedGet
method has already restored the interrupt after catching the exception. If an implementation ofmapException(Exception)
wishes to swallow the interrupt, it can do so by callingThread.interrupted()
.Subclasses may choose to throw, rather than return, a subclass of
RuntimeException
to allow creating a CheckedFuture that throws both checked and unchecked exceptions.
checkedGet
public V checkedGet() throws X extends Exception
- Exception checking version of
Future.get()
that will translateInterruptedException
,CancellationException
andExecutionException
into application-specific exceptions.This implementation calls
ForwardingFuture.get()
and maps that method's standard exceptions to instances of typeX
usingmapException(java.lang.Exception)
.In addition, if
get
throws anInterruptedException
, this implementation will set the current thread's interrupt status before callingmapException
.- Specified by:
checkedGet
in interfaceCheckedFuture<V,X extends Exception>
- Returns:
- the result of executing the future.
- Throws:
X
- ifForwardingFuture.get()
throws anInterruptedException
,CancellationException
, orExecutionException
X extends Exception
checkedGet
public V checkedGet(long timeout, TimeUnit unit) throws TimeoutException, X extends Exception
- Exception checking version of
Future.get(long, TimeUnit)
that will translateInterruptedException
,CancellationException
andExecutionException
into application-specific exceptions. On timeout this method throws a normalTimeoutException
.This implementation calls
ForwardingFuture.get(long, TimeUnit)
and maps that method's standard exceptions (excludingTimeoutException
, which is propagated) to instances of typeX
usingmapException(java.lang.Exception)
.In addition, if
get
throws anInterruptedException
, this implementation will set the current thread's interrupt status before callingmapException
.- Specified by:
checkedGet
in interfaceCheckedFuture<V,X extends Exception>
- Returns:
- the result of executing the future.
- Throws:
X
- ifForwardingFuture.get()
throws anInterruptedException
,CancellationException
, orExecutionException
TimeoutException
- if retrieving the result timed out.X extends Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2010-2012. All Rights Reserved.