public static class F.Promise<A>
extends java.lang.Object
A.| Constructor and Description |
|---|
F.Promise(A a)
Create a new pure promise, that is, a promise with a constant value from the start.
|
F.Promise(play.api.libs.concurrent.Promise<A> promise)
Create a new promise wrapping the given Scala promise
|
| Modifier and Type | Method and Description |
|---|---|
<B> F.Promise<B> |
flatMap(F.Function<A,F.Promise<B>> function)
Maps the result of this promise to a promise for a result of type
B, and flattens that to be
a single promise for B. |
A |
get()
Awaits for the promise to get the result using the default timeout (5000 milliseconds).
|
A |
get(java.lang.Long timeout)
Awaits for the promise to get the result.
|
A |
get(java.lang.Long timeout,
java.util.concurrent.TimeUnit unit)
Awaits for the promise to get the result.
|
play.api.libs.concurrent.Promise<A> |
getWrappedPromise()
Get the underlying Scala promise
|
<B> F.Promise<B> |
map(F.Function<A,B> function)
Maps this promise to a promise of type
B. |
void |
onRedeem(F.Callback<A> action)
Perform the given
action callback when the Promise is redeemed. |
F.Promise<A> |
recover(F.Function<java.lang.Throwable,A> function)
Wraps this promise in a promise that will handle exceptions thrown by this Promise.
|
static <A> F.Promise<java.util.List<A>> |
waitAll(F.Promise<A>... promises)
Combine the given promises into a single promise for the list of results.
|
static <A> F.Promise<java.util.List<A>> |
waitAll(java.lang.Iterable<F.Promise<A>> promises)
Combine the given promises into a single promise for the list of results.
|
public F.Promise(play.api.libs.concurrent.Promise<A> promise)
promise - The scala promise to wrappublic F.Promise(A a)
a - the value for the promisepublic static <A> F.Promise<java.util.List<A>> waitAll(F.Promise<A>... promises)
promises - The promises to combinepublic static <A> F.Promise<java.util.List<A>> waitAll(java.lang.Iterable<F.Promise<A>> promises)
promises - The promises to combinepublic A get()
java.lang.RuntimeException - if the calculation providing the promise threw an exceptionpublic A get(java.lang.Long timeout, java.util.concurrent.TimeUnit unit)
timeout - A user defined timeoutunit - timeout for timeoutjava.lang.RuntimeException - if the calculation providing the promise threw an exceptionpublic A get(java.lang.Long timeout)
timeout - A user defined timeout in millisecondsjava.lang.RuntimeException - if the calculation providing the promise threw an exceptionpublic void onRedeem(F.Callback<A> action)
action callback when the Promise is redeemed.action - The action to perform.public <B> F.Promise<B> map(F.Function<A,B> function)
B. The function function is applied as
soon as the promise is redeemed.
Exceptions thrown by function will be wrapped in RuntimeException, unless
they are RuntimeException's themselves.function - The function to map A to B.A to B.public F.Promise<A> recover(F.Function<java.lang.Throwable,A> function)
function will be wrapped in RuntimeException, unless
they are RuntimeException's themselves.function - The function to handle the exception. This may, for example, convert the exception into something
of type T, or it may throw another exception, or it may do some other handling.function throws an
exception.public <B> F.Promise<B> flatMap(F.Function<A,F.Promise<B>> function)
B, and flattens that to be
a single promise for B.
Exceptions thrown by function will be wrapped in RuntimeException, unless
they are RuntimeException's themselves.function - The function to map A to a promise for B.Bpublic play.api.libs.concurrent.Promise<A> getWrappedPromise()