public static class F.Promise<A>
extends java.lang.Object
A.| Constructor and Description |
|---|
F.Promise(scala.concurrent.Future<A> future)
Deprecated.
Since 2.2. Use
wrap(Future) instead. |
| Modifier and Type | Method and Description |
|---|---|
static <A> F.Promise<A> |
delayed(F.Function0<A> function,
long delay,
java.util.concurrent.TimeUnit unit)
Create a Promise which, after a delay, will be redeemed with the result of a
given function.
|
static <A> F.Promise<A> |
delayed(F.Function0<A> function,
long delay,
java.util.concurrent.TimeUnit unit,
scala.concurrent.ExecutionContext ec)
Create a Promise which, after a delay, will be redeemed with the result of a
given function.
|
F.Promise<A> |
fallbackTo(F.Promise<A> fallback)
Creates a new promise which holds the result of this promise if it was completed successfully,
otherwise the result of the
fallback promise if it completed successfully. |
F.Promise<A> |
filter(F.Predicate<? super A> predicate)
Creates a new promise by filtering the value of the current promise with a predicate.
|
F.Promise<A> |
filter(F.Predicate<? super A> predicate,
scala.concurrent.ExecutionContext ec)
Creates a new promise by filtering the value of the current promise with a predicate.
|
<B> F.Promise<B> |
flatMap(F.Function<? super 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. |
<B> F.Promise<B> |
flatMap(F.Function<? super A,F.Promise<B>> function,
scala.concurrent.ExecutionContext ec)
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(long timeout)
Awaits for the promise to get the result.
Throws a Throwable if the calculation providing the promise threw an exception |
A |
get(long timeout,
java.util.concurrent.TimeUnit unit)
Awaits for the promise to get the result.
Throws a Throwable if the calculation providing the promise threw an exception |
<B> F.Promise<B> |
map(F.Function<? super A,B> function)
Maps this promise to a promise of type
B. |
<B> F.Promise<B> |
map(F.Function<? super A,B> function,
scala.concurrent.ExecutionContext ec)
Maps this promise to a promise of type
B. |
void |
onFailure(F.Callback<java.lang.Throwable> action)
Perform the given
action callback if the promise encounters an exception. |
void |
onFailure(F.Callback<java.lang.Throwable> action,
scala.concurrent.ExecutionContext ec)
Perform the given
action callback if the promise encounters an exception. |
void |
onRedeem(F.Callback<A> action)
Perform the given
action callback when the Promise is redeemed. |
void |
onRedeem(F.Callback<A> action,
scala.concurrent.ExecutionContext ec)
Perform the given
action callback when the Promise is redeemed. |
<B> F.Promise<F.Either<A,B>> |
or(F.Promise<B> another)
combines the current promise with
another promise using `or` |
static <A> F.Promise<A> |
promise(F.Function0<A> function)
Create a Promise which will be redeemed with the result of a given function.
|
static <A> F.Promise<A> |
promise(F.Function0<A> function,
scala.concurrent.ExecutionContext ec)
Create a Promise which will be redeemed with the result of a given Function0.
|
static <A> F.Promise<A> |
pure(A a)
Create a new pure promise, that is, a promise with a constant value from the start.
|
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.
|
F.Promise<A> |
recover(F.Function<java.lang.Throwable,A> function,
scala.concurrent.ExecutionContext ec)
Wraps this promise in a promise that will handle exceptions thrown by this Promise.
|
F.Promise<A> |
recoverWith(F.Function<java.lang.Throwable,F.Promise<A>> function)
Creates a new promise that will handle thrown exceptions by assigning to the value of another promise.
|
F.Promise<A> |
recoverWith(F.Function<java.lang.Throwable,F.Promise<A>> function,
scala.concurrent.ExecutionContext ec)
Creates a new promise that will handle thrown exceptions by assigning to the value of another promise.
|
static <A> F.Promise<java.util.List<A>> |
sequence(scala.concurrent.ExecutionContext ec,
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>> |
sequence(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>> |
sequence(java.lang.Iterable<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>> |
sequence(java.lang.Iterable<F.Promise<A>> promises,
scala.concurrent.ExecutionContext ec)
Combine the given promises into a single promise for the list of results.
|
static <A> F.Promise<A> |
throwing(java.lang.Throwable throwable)
Create a new promise throwing an exception.
|
static <A> F.Promise<A> |
timeout(A message,
long delay)
Create a Promise that is redeemed after a timeout.
|
static <A> F.Promise<A> |
timeout(A message,
long delay,
java.util.concurrent.TimeUnit unit)
Create a Promise that is redeemed after a timeout.
|
static <A> F.Promise<scala.Unit> |
timeout(long delay)
Create a Promise timer that throws a TimeoutException after a
given timeout.
|
static <A> F.Promise<scala.Unit> |
timeout(long delay,
java.util.concurrent.TimeUnit unit)
Create a Promise timer that throws a TimeoutException after a
given timeout.
|
<B> F.Promise<B> |
transform(F.Function<? super A,B> onSuccess,
F.Function<java.lang.Throwable,java.lang.Throwable> onFailure)
Creates a new promise by applying the
onSuccess function to a successful result,
or the onFailure function to a failed result. |
<B> F.Promise<B> |
transform(F.Function<? super A,B> onSuccess,
F.Function<java.lang.Throwable,java.lang.Throwable> onFailure,
scala.concurrent.ExecutionContext ec)
Creates a new promise by applying the
onSuccess function to a successful result,
or the onFailure function to a failed result. |
static <A> F.Promise<A> |
wrap(scala.concurrent.Future<A> future)
Creates a Promise that wraps a Scala Future.
|
scala.concurrent.Future<A> |
wrapped()
Gets the Scala Future wrapped by this Promise.
|
<B> F.Promise<F.Tuple<A,B>> |
zip(F.Promise<B> another)
Zips the values of this promise with
another, and creates a new promise holding the tuple of their results |
@Deprecated public F.Promise(scala.concurrent.Future<A> future)
wrap(Future) instead.future - The Scala Future to wrappublic static <A> F.Promise<A> wrap(scala.concurrent.Future<A> future)
future - The Scala Future to wrappublic static <A> F.Promise<java.util.List<A>> sequence(F.Promise<A>... promises)
promises - The promises to combinepublic static <A> F.Promise<java.util.List<A>> sequence(scala.concurrent.ExecutionContext ec, F.Promise<A>... promises)
ec - Used to execute the sequencing operations.promises - The promises to combinepublic static <A> F.Promise<A> timeout(A message, long delay, java.util.concurrent.TimeUnit unit)
message - The message to use to redeem the Promise.delay - The delay (expressed with the corresponding unit).unit - The Unit.public static <A> F.Promise<A> timeout(A message, long delay)
message - The message to use to redeem the Promise.delay - The delay expressed in milliseconds.public static <A> F.Promise<scala.Unit> timeout(long delay)
delay - The delay expressed in milliseconds.public static <A> F.Promise<scala.Unit> timeout(long delay, java.util.concurrent.TimeUnit unit)
delay - The delay (expressed with the corresponding unit).unit - The Unit.public static <A> F.Promise<java.util.List<A>> sequence(java.lang.Iterable<F.Promise<A>> promises)
promises - The promises to combinepublic static <A> F.Promise<java.util.List<A>> sequence(java.lang.Iterable<F.Promise<A>> promises, scala.concurrent.ExecutionContext ec)
promises - The promises to combineec - Used to execute the sequencing operations.public static <A> F.Promise<A> pure(A a)
a - the value for the promisepublic static <A> F.Promise<A> throwing(java.lang.Throwable throwable)
throwable - Value to throwpublic static <A> F.Promise<A> promise(F.Function0<A> function)
function - Used to fulfill the Promise.public static <A> F.Promise<A> promise(F.Function0<A> function, scala.concurrent.ExecutionContext ec)
function - Used to fulfill the Promise.ec - The ExecutionContext to run the function in.public static <A> F.Promise<A> delayed(F.Function0<A> function, long delay, java.util.concurrent.TimeUnit unit)
function - The function to call to fulfill the Promise.delay - The time to wait.unit - The units to use for the delay.public static <A> F.Promise<A> delayed(F.Function0<A> function, long delay, java.util.concurrent.TimeUnit unit, scala.concurrent.ExecutionContext ec)
function - The function to call to fulfill the Promise.delay - The time to wait.unit - The units to use for the delay.ec - The ExecutionContext to run the Function0 in.public A get(long timeout, java.util.concurrent.TimeUnit unit)
timeout - A user defined timeoutunit - timeout for timeoutpublic A get(long timeout)
timeout - A user defined timeout in millisecondspublic <B> F.Promise<F.Either<A,B>> or(F.Promise<B> another)
another promise using `or`another - public void onRedeem(F.Callback<A> action)
action callback when the Promise is redeemed.
The callback will be run in the default execution context.action - The action to perform.public void onRedeem(F.Callback<A> action, scala.concurrent.ExecutionContext ec)
action callback when the Promise is redeemed.action - The action to perform.ec - The ExecutionContext to execute the action in.public <B> F.Promise<B> map(F.Function<? super A,B> function)
B. The function function is applied as
soon as the promise is redeemed.
The function will be run in the default execution context.function - The function to map A to B.A to B.public <B> F.Promise<B> map(F.Function<? super A,B> function, scala.concurrent.ExecutionContext ec)
B. The function function is applied as
soon as the promise is redeemed.function - The function to map A to B.ec - The ExecutionContext to execute the function in.A to B.public F.Promise<A> recover(F.Function<java.lang.Throwable,A> function)
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 F.Promise<A> recover(F.Function<java.lang.Throwable,A> function, scala.concurrent.ExecutionContext ec)
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.ec - The ExecutionContext to execute the function in.function throws an
exception.public F.Promise<A> recoverWith(F.Function<java.lang.Throwable,F.Promise<A>> function)
function - The function to handle the exception, and which returns another promisepublic F.Promise<A> recoverWith(F.Function<java.lang.Throwable,F.Promise<A>> function, scala.concurrent.ExecutionContext ec)
function - The function to handle the exception, and which returns another promiseec - The ExecutionContext to execute the function inpublic F.Promise<A> fallbackTo(F.Promise<A> fallback)
fallback promise if it completed successfully.
If both promises failed, the resulting promise holds the throwable of this promise.fallback - The promise to fallback to if this promise has failedpublic void onFailure(F.Callback<java.lang.Throwable> action)
action callback if the promise encounters an exception.
This action will be run in the default exceution context.action - The action to perform.public void onFailure(F.Callback<java.lang.Throwable> action, scala.concurrent.ExecutionContext ec)
action callback if the promise encounters an exception.action - The action to perform.ec - The ExecutionContext to execute the callback in.public <B> F.Promise<B> flatMap(F.Function<? super A,F.Promise<B>> function)
B, and flattens that to be
a single promise for B.
The function will be run in the default execution context.function - The function to map A to a promise for B.Bpublic <B> F.Promise<B> flatMap(F.Function<? super A,F.Promise<B>> function, scala.concurrent.ExecutionContext ec)
B, and flattens that to be
a single promise for B.function - The function to map A to a promise for B.ec - The ExecutionContext to execute the function in.Bpublic F.Promise<A> filter(F.Predicate<? super A> predicate)
predicate - The predicate to test the current value.public F.Promise<A> filter(F.Predicate<? super A> predicate, scala.concurrent.ExecutionContext ec)
predicate - The predicate to test the current value.ec - The ExecutionContext to execute the filtering in.public <B> F.Promise<B> transform(F.Function<? super A,B> onSuccess, F.Function<java.lang.Throwable,java.lang.Throwable> onFailure)
onSuccess function to a successful result,
or the onFailure function to a failed result.
The function will be run in the default execution context.onSuccess - The function to map a successful result from A to BonFailure - The function to map the Throwable when failedonSuccess or onFailure functionspublic <B> F.Promise<B> transform(F.Function<? super A,B> onSuccess, F.Function<java.lang.Throwable,java.lang.Throwable> onFailure, scala.concurrent.ExecutionContext ec)
onSuccess function to a successful result,
or the onFailure function to a failed result.onSuccess - The function to map a successful result from A to BonFailure - The function to map the Throwable when failedec - The ExecutionContext to execute functions inonSuccess or onFailure functionspublic <B> F.Promise<F.Tuple<A,B>> zip(F.Promise<B> another)
another, and creates a new promise holding the tuple of their resultsanother - public scala.concurrent.Future<A> wrapped()