T - the type of value that can be setpublic class ReadyFuture<T> extends ReadyPartialFuture<T> implements Future<T>
Future that is always in the "set" state. No call on a ReadyFuture
will block, since this is either a value or an error from its time of creation. A
ReadyFuture is useful for returning the result of an asynchronous process.Future<Void> to indicate completion,
DONE should be used.| Modifier and Type | Field and Description |
|---|---|
static Future<Void> |
DONE
A set
Future that indicates a process has completed successfully. |
| Constructor and Description |
|---|
ReadyFuture(Error error)
Create a new
ReadyFuture set to an error. |
ReadyFuture(Error error,
Executor executor)
Create a new
ReadyFuture set to an error. |
ReadyFuture(RuntimeException error)
Create a new
ReadyFuture set to an error. |
ReadyFuture(RuntimeException error,
Executor executor)
Create a new
ReadyFuture set to an error. |
ReadyFuture(T value)
Create a new
ReadyFuture set to a value. |
ReadyFuture(T value,
Executor executor)
Create a new
ReadyFuture set to a value. |
| Modifier and Type | Method and Description |
|---|---|
<V> Future<V> |
flatMap(Function<? super T,Future<V>> m)
Applies the successful result of this operation as the input into another asynchronous
operation and returns a handle to that result.
|
T |
get()
Blocks until a value is set on this
PartialFuture and returns it. |
T |
getInterruptibly()
Blocks until a value is set on this
PartialFuture and returns it. |
<V> Future<V> |
map(Function<? super T,V> m)
Apply a function to the successful result of this operation.
|
Future<T> |
rescueRuntime(Function<? super RuntimeException,Future<T>> m)
Returns a
Future that modifies the error behavior of this Future. |
blockInterruptibly, blockUntilReady, cancel, dispose, flatMap, getError, isDone, isError, map, onReady, onReadyAlready, rescue, rescueequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitblockInterruptibly, blockUntilReady, cancel, dispose, flatMap, isDone, isError, map, onReady, onReadyAlready, rescue, rescuepublic ReadyFuture(T value)
ReadyFuture set to a value.value - the final value of this Futurepublic ReadyFuture(Error error)
ReadyFuture set to an error. If error is null the
Future will be set to a null value and NOT an error.error - the final error of this Futurepublic ReadyFuture(RuntimeException error)
ReadyFuture set to an error. If error is null the
Future will be set to a null value and NOT an error.error - the final error of this Futurepublic ReadyFuture(T value, Executor executor)
ReadyFuture set to a value.value - the final value of this Futureexecutor - the executor with which to execute callbackspublic ReadyFuture(Error error, Executor executor)
ReadyFuture set to an error. If error is null the
Future will be set to a null value and NOT an error.error - the final error of this Futureexecutor - the executor with which to execute callbackspublic ReadyFuture(RuntimeException error, Executor executor)
ReadyFuture set to an error. If error is null the
Future will be set to a null value and NOT an error.error - the final error of this Futureexecutor - the executor with which to execute callbackspublic T get()
PartialFuturePartialFuture and returns it.
If this PartialFuture is set to an Exception or Error
this call will throw that error.get in interface Future<T>get in interface PartialFuture<T>get in class ReadyPartialFuture<T>public T getInterruptibly()
PartialFuturePartialFuture and returns it.
If this PartialFuture is set to an Exception or Error
this call will throw that error.getInterruptibly in interface Future<T>getInterruptibly in interface PartialFuture<T>getInterruptibly in class ReadyPartialFuture<T>public <V> Future<V> map(Function<? super T,V> m)
Futuremap(), since it accepts only Functions that cannot throw checked
exceptions, returns a Future. Errors encountered
in the execution of this operation are sent to the resulting Future.Future is cancelled the input
Future will also be cancelled.public <V> Future<V> flatMap(Function<? super T,Future<V>> m)
FutureFuture is complete and a result
is returned, the Mapper m is invoked to begin a new asynchronous process
using the result. This version of
map(), since it accepts only Functions that cannot throw checked
exceptions, returns a Future.
Errors in the execution of either operation are sent to the resulting Future.Future is cancelled the input
Future will also be cancelled.public Future<T> rescueRuntime(Function<? super RuntimeException,Future<T>> m)
FutureFuture that modifies the error behavior of this Future.
Since Future cannot be set to an Exception other than a
RuntimeException, the handling Function need not handle other,
more general, types. If an Error is the output of this process, this handler
is not invoked and that Error will be passed on to the resulting Future.rescueRuntime in interface Future<T>m - the process to run that maps an error into another asynchronous operationFuture with modified error behavior