This class is not used directly by clients. Clients should use
PromiseFactory#failed(Throwable) to create a failed Promise.
| Modifier and Type | Field and Description |
|---|---|
| private final Throwable | fail
The failure of this failed Promise. |
| Access | Constructor and Description |
|---|---|
| pack-priv | FailedPromiseImpl(Throwable
The failure of this failed Promise. Must not be fail, PromiseFactory null.The factory to use for callbacks and scheduled operations. factory)Initialize this failed Promise. |
| Modifier and Type | Method and Description |
|---|---|
| private <V> FailedPromiseImpl | |
| public Promise | filter(Predicate<? super T>
The Predicate to evaluate the value of this Promise.
Must not be predicate)null.Overrides org. Implements org. Filter the value of this Promise. |
| public <R> Promise | flatMap(Function<? super T, Promise<? extends R>>
The Function that must flatMap the value of this Promise to
a Promise that must be used to resolve the returned Promise. Must
not be mapper)null.Overrides org. Implements org. FlatMap the value of this Promise. |
| public Throwable | getFailure()
Implements org. Returns the failure of this Promise. |
| public T | |
| public boolean | isDone()
Implements org. Returns whether this Promise has been resolved. |
| public <R> Promise | map(Function<? super T, ? extends R>
The Function that must map the value of this Promise to the
value that must be used to resolve the returned Promise. Must not
be mapper)null.Overrides org. Implements org. Map the value of this Promise. |
| public Promise | onSuccess(Consumer<? super T>
The Consumer callback that receives the value of this
Promise. Must not be success)null.Overrides org. Implements org. Register a callback to be called with the result of this Promise when this Promise is resolved successfully. |
| pack-priv void | result(PromiseImpl.
Implements abstract org. Accept the result of this PromiseImpl. |
| public <R> Promise | then(Success<? super T, ? extends R>
The Success callback to be called when this Promise is
successfully resolved. May be success, Failure 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.The Failure callback to be called when this Promise is
resolved with a failure. May be failure)null if no Failure
callback is required.Overrides org. Implements org. Chain a new Promise to this Promise with Success and Failure callbacks. |
| public Promise | thenAccept(Consumer<? super T>
The Consumer callback that receives the value of this
Promise. Must not be consumer)null.Overrides org. Implements org. Chain a new Promise to this Promise with a Consumer callback that receives the value of this Promise when it is successfully resolved. |
| public Promise | timeout(long
The time to wait in milliseconds. Zero and negative
time is treated as an immediate timeout. millis)Overrides org. Implements org. Time out the resolution of this Promise. |
| public CompletionStage | toCompletionStage()
Overrides org. Implements org. Returns a new CompletionStage that will be resolved with the result of this Promise. |
| public String |
| fail | back to summary |
|---|---|
| private final Throwable fail The failure of this failed Promise. | |
| FailedPromiseImpl | back to summary |
|---|---|
| pack-priv FailedPromiseImpl(Throwable fail, PromiseFactory factory) Initialize this failed Promise.
| |
| coerce | back to summary |
|---|---|
| private <V> FailedPromiseImpl Coerce the value type of this FailedPromiseImpl.
| |
| filter | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Filter the value of this Promise.
If this Promise is successfully resolved, the returned Promise must
either be resolved with the value of this Promise, if the specified
Predicate accepts that value, or failed with a
If this Promise is resolved with a failure, the returned Promise must be failed with that failure. This method may be called at any time including before and after this Promise has been resolved.
| |
| flatMap | back to summary |
|---|---|
| public <R> Promise Overrides org. Implements org. Doc from org. FlatMap the value of this Promise. If this Promise is successfully resolved, the returned Promise must be resolved with the Promise from the specified Function as applied to the value of this Promise. If the specified Function throws an exception, the returned Promise must be failed with the exception. If this Promise is resolved with a failure, the returned Promise must be failed with that failure. This method may be called at any time including before and after this Promise has been resolved.
| |
| getFailure | back to summary |
|---|---|
| public Throwable getFailure() Implements org. Doc from org. Returns the failure of this Promise.
If this Promise is not
If this Promise was resolved with a failure, this method returns with the
failure of this Promise. If this Promise was successfully resolved, this
method must return | |
| getValue | back to summary |
|---|---|
| public T getValue() throws InvocationTargetException Implements org. Doc from org. Returns the value of this Promise.
If this Promise is not
If this Promise was successfully resolved, this method returns with the
value of this Promise. If this Promise was resolved with a failure, this
method must throw an
| |
| isDone | back to summary |
|---|---|
| public boolean isDone() Implements org. Doc from org. Returns whether this Promise has been resolved. This Promise may be successfully resolved or resolved with a failure.
| |
| map | back to summary |
|---|---|
| public <R> Promise Overrides org. Implements org. Doc from org. Map the value of this Promise. If this Promise is successfully resolved, the returned Promise must be resolved with the value of specified Function as applied to the value of this Promise. If the specified Function throws an exception, the returned Promise must be failed with the exception. If this Promise is resolved with a failure, the returned Promise must be failed with that failure. This method may be called at any time including before and after this Promise has been resolved.
| |
| onSuccess | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Register a callback to be called with the result of this Promise when this Promise is resolved successfully. The callback will not be called if this Promise is resolved with a failure. This method may be called at any time including before and after this Promise has been resolved.
Resolving this Promise happens-before any registered callback is
called. That is, in a registered callback, A callback may be called on a different thread than the thread which registered the callback. So the callback must be thread safe but can rely upon that the registration of the callback happens-before the registered callback is called.
| |
| result | back to summary |
|---|---|
| pack-priv void result(PromiseImpl. Implements abstract org. Doc from org. Accept the result of this PromiseImpl.
| |
| then | back to summary |
|---|---|
| public <R> Promise Overrides org. Implements org. Doc from org. Chain a new Promise to this Promise with Success and Failure callbacks.
The specified This method returns a new Promise which is chained to this Promise. The returned Promise must be resolved when this Promise is resolved after the specified Success or Failure callback is executed. The result of the executed callback must be used to resolve the returned Promise. Multiple calls to this method can be used to create a chain of promises which are resolved in sequence. If this Promise is successfully resolved, the Success callback is executed and the result Promise, if any, or thrown exception is used to resolve the returned Promise from this method. If this Promise is resolved with a failure, the Failure callback is executed and the returned Promise from this method is failed. This method may be called at any time including before and after this Promise has been resolved.
Resolving this Promise happens-before any registered callback is
called. That is, in a registered callback, A callback may be called on a different thread than the thread which registered the callback. So the callback must be thread safe but can rely upon that the registration of the callback happens-before the registered callback is called.
| |
| thenAccept | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Chain a new Promise to this Promise with a Consumer callback that receives the value of this Promise when it is successfully resolved.
The specified This method returns a new Promise which is chained to this Promise. The returned Promise must be resolved when this Promise is resolved after the specified callback is executed. If the callback throws an exception, the returned Promise is failed with that exception. Otherwise the returned Promise is resolved with the success value from this Promise. This method may be called at any time including before and after this Promise has been resolved.
Resolving this Promise happens-before any registered callback is
called. That is, in a registered callback, A callback may be called on a different thread than the thread which registered the callback. So the callback must be thread safe but can rely upon that the registration of the callback happens-before the registered callback is called.
| |
| timeout | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Time out the resolution of this Promise.
If this Promise is successfully resolved before the timeout, the returned
Promise is resolved with the value of this Promise. If this Promise is
resolved with a failure before the timeout, the returned Promise is
resolved with the failure of this Promise. If the timeout is reached
before this Promise is resolved, the returned Promise is failed with a
| |
| toCompletionStage | back to summary |
|---|---|
| public CompletionStage Overrides org. Implements org. Doc from org. Returns a new CompletionStage that will be resolved with the result of this Promise.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |