| Constructor and Description |
|---|
PromiseImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
fail(Throwable failure) |
Promise<T> |
fallbackTo(Promise<? extends T> fallback)
Fall back to the value of the specified Promise if this Promise fails.
|
Promise<T> |
filter(Predicate<? super T> predicate)
Filter the value of this Promise.
|
<R> Promise<R> |
flatMap(Function<? super T,Promise<? extends R>> mapper)
FlatMap the value of this Promise.
|
Throwable |
getFailure()
Returns the failure of this Promise.
|
T |
getValue()
Returns the value of this Promise.
|
boolean |
isDone()
Returns whether this Promise has been resolved.
|
<R> Promise<R> |
map(Function<? super T,? extends R> mapper)
Map the value of this Promise.
|
Promise<T> |
onResolve(Runnable callback)
Register a callback to be called when this Promise is resolved.
|
Promise<T> |
recover(Function<Promise<?>,? extends T> recovery)
Recover from a failure of this Promise with a recovery value.
|
Promise<T> |
recoverWith(Function<Promise<?>,Promise<? extends T>> recovery)
Recover from a failure of this Promise with a recovery Promise.
|
void |
resolve(T value) |
Promise<Void> |
resolveWith(Promise<? extends T> with) |
<R> Promise<R> |
then(Success<? super T,? extends R> success)
Chain a new Promise to this Promise with a Success callback.
|
<R> Promise<R> |
then(Success<? super T,? extends R> success,
Failure failure)
Chain a new Promise to this Promise with Success and Failure callbacks.
|
public void fail(Throwable failure)
public void resolve(T value)
public boolean isDone()
Promisepublic T getValue() throws InvocationTargetException, InterruptedException
PromisegetValue in interface Promise<T>InvocationTargetException - If this Promise was resolved with a failure. The cause of the
InvocationTargetException is the failure exception.InterruptedException - If the current thread was interrupted while waiting.public Throwable getFailure() throws InterruptedException
PromisegetFailure in interface Promise<T>InterruptedException - If the current thread was interrupted while waiting.public Promise<T> onResolve(Runnable callback)
Promisepublic <R> Promise<R> then(Success<? super T,? extends R> success, Failure failure)
Promisethen in interface Promise<T>R - The value type associated with the returned Promise.success - A Success callback to be called when this Promise is successfully resolved. May be null if no
Success callback is required. In thifailure - A Failure callback to be called when this Promise is resolved with a failure. May be null if no
Failure callback is required.public <R> Promise<R> then(Success<? super T,? extends R> success)
Promisethen in interface Promise<T>R - The value type associated with the returned Promise.success - A Success callback to be called when this Promise is successfully resolved. May be null if no
Success callback is required. In this case, the returned Promise must be resolved with the value
null when this Promise is successfully resolved.Promise.then(Success, Failure)public Promise<T> filter(Predicate<? super T> predicate)
Promisepublic <R> Promise<R> map(Function<? super T,? extends R> mapper)
Promisemap in interface Promise<T>R - The value type associated with the returned Promise.mapper - The Function that will map the value of this Promise to the value that will be used to resolve the
returned Promise. Must not be null.public <R> Promise<R> flatMap(Function<? super T,Promise<? extends R>> mapper)
PromiseflatMap in interface Promise<T>R - The value type associated with the returned Promise.mapper - The Function that will flatMap the value of this Promise to a Promise that will be used to resolve
the returned Promise. Must not be null.public Promise<T> recover(Function<Promise<?>,? extends T> recovery)
Promiserecover in interface Promise<T>recovery - If this Promise resolves with a failure, the specified Function is called to produce a recovery
value to be used to resolve the returned Promise. Must not be null.public Promise<T> recoverWith(Function<Promise<?>,Promise<? extends T>> recovery)
PromiserecoverWith in interface Promise<T>recovery - If this Promise resolves with a failure, the specified Function is called to produce a recovery
Promise to be used to resolve the returned Promise. Must not be null.public Promise<T> fallbackTo(Promise<? extends T> fallback)
PromisefallbackTo in interface Promise<T>fallback - The Promise whose value will be used to resolve the returned Promise if this Promise resolves
with a failure. Must not be null.Copyright © 2009-2015 The Apache Software Foundation. All Rights Reserved.