Class SettableFuture<V>
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractFuture<V>
-
- com.google.common.util.concurrent.SettableFuture<V>
-
- All Implemented Interfaces:
ListenableFuture<V>
,java.util.concurrent.Future<V>
public final class SettableFuture<V> extends AbstractFuture<V>
AListenableFuture
whose result may be set by aset(Object)
orsetException(Throwable)
call. It may also be cancelled.- Since:
- 9.0 (in 1.0 as
ValueFuture
)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <V> SettableFuture<V>
create()
Creates a newSettableFuture
in the default state.boolean
set(V value)
Sets the value of this future.boolean
setException(java.lang.Throwable throwable)
Sets the future to having failed with the given exception.-
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
addListener, cancel, get, get, isCancelled, isDone
-
-
-
-
Method Detail
-
create
public static <V> SettableFuture<V> create()
Creates a newSettableFuture
in the default state.
-
set
public boolean set(@Nullable V value)
Sets the value of this future. This method will returntrue
if the value was successfully set, orfalse
if the future has already been set or cancelled.- Parameters:
value
- the value the future should hold.- Returns:
- true if the value was successfully set.
-
setException
public boolean setException(java.lang.Throwable throwable)
Sets the future to having failed with the given exception. This exception will be wrapped in anExecutionException
and thrown from theget
methods. This method will returntrue
if the exception was successfully set, orfalse
if the future has already been set or cancelled.- Parameters:
throwable
- the exception the future should hold.- Returns:
- true if the exception was successfully set.
-
-