This class is not used directly by clients. Clients should use
PromiseFactory#resolved(Object) to create a resolved Promise.
| Modifier and Type | Field and Description |
|---|---|
| private final T | value
The value of this resolved Promise. |
| Access | Constructor and Description |
|---|---|
| pack-priv | ResolvedPromiseImpl(T
The value of this resolved Promise. value, PromiseFactory The factory to use for callbacks and scheduled operations. factory)Initialize this resolved Promise. |
| Modifier and Type | Method and Description |
|---|---|
| public Promise | fallbackTo(Promise<? extends T>
The Promise whose value must be used to resolve the
returned Promise if this Promise resolves with a failure. Must not
be fallback)null.Overrides org. Implements org. Fall back to the value of the specified Promise if this Promise fails. |
| public Promise | fallbackTo(Promise<? extends T>
The Promise whose value must be used to resolve the
returned Promise if this Promise resolves with a failure and
the failure is an instance of the specified failure type. Must
not be fallback, Class<?> null.The type of failure for which this recovery will be
used. If the failure is not an instance of the failure type,
the specified recovery will not be called and the returned
Promise must be failed with the failure of this Promise. Must
not be failureType)null.Overrides org. Implements org. Fall back to the value of the specified Promise if this Promise fails and the failure is an instance of a failure type. |
| 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 Promise | onFailure(Consumer<? super Throwable>
The Consumer callback that receives the failure of this
Promise. Must not be failure)null.Overrides org. Implements org. Register a callback to be called with the failure for this Promise when this Promise is resolved with a failure. |
| public <F> Promise | onFailure(Consumer<? super F>
The Consumer callback that receives the failure of this
Promise if the failure is an instance of the specified failure
type. Must not be failure, Class<? extends F> null.The type of failure for which this callback will be
called. If the failure is not an instance of the specified
failure type, the specified callback will not be called. Must
not be failureType)null.Overrides org. Implements org. Register a callback to be called with the failure for this Promise when this Promise is resolved with a failure of a failure type. |
| public Promise | recover(Function<Promise<?>, ? extends T>
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 recovery)null.Overrides org. Implements org. Recover from a failure of this Promise with a recovery value. |
| public Promise | recover(Function<Promise<?>, ? extends T>
If this Promise resolves with a failure and the failure
is an instance of the specified failure type, the specified
Function is called to produce a recovery value to be used to
resolve the returned Promise. Must not be recovery, Class<?> null.The type of failure for which the specified recovery
will be used. If the failure is not an instance of the failure
type, the specified recovery will not be called and the
returned Promise must be failed with the failure of this
Promise. Must not be failureType)null.Overrides org. Implements org. Recover from a failure of this Promise with a recovery value if the failure is an instance of a failure type. |
| public Promise | recoverWith(Function<Promise<?>, Promise<? extends T>>
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 recovery)null.Overrides org. Implements org. Recover from a failure of this Promise with a recovery Promise. |
| public Promise | recoverWith(Function<Promise<?>, Promise<? extends T>>
If this Promise resolves with a failure and the failure
is an instance of the specified failure type, the specified
Function is called to produce a recovery Promise to be used to
resolve the returned Promise. Must not be recovery, Class<?> null.The type of failure for which this recovery will be
used. If the failure is not an instance of the failure type,
the specified recovery will not be called and the returned
Promise must be failed with the failure of this Promise. Must
not be failureType)null.Overrides org. Implements org. Recover from a failure of this Promise with a recovery Promise if the failure is an instance of a failure type. |
| 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 | 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 |
| value | back to summary |
|---|---|
| private final T value The value of this resolved Promise. | |
| ResolvedPromiseImpl | back to summary |
|---|---|
| pack-priv ResolvedPromiseImpl(T value, PromiseFactory factory) Initialize this resolved Promise.
| |
| fallbackTo | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Fall back to the value of the specified Promise if this Promise fails. If this Promise is successfully resolved, the returned Promise must be resolved with the value of this Promise. If this Promise is resolved with a failure, the successful result of the specified Promise is used to resolve the returned Promise. If the specified Promise is resolved with a failure, the returned Promise must be failed with the failure of this Promise rather than the failure of the specified Promise. This method may be called at any time including before and after this Promise has been resolved.
| |
| fallbackTo | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Fall back to the value of the specified Promise if this Promise fails and the failure is an instance of a failure type. If this Promise is successfully resolved, the returned Promise must be resolved with the value of this Promise. If this Promise is resolved with a failure and the failure is an instance of the specified failure type, the successful result of the specified Promise is used to resolve the returned Promise. If the specified Promise is resolved with a failure, the returned Promise must be failed with the failure of this Promise rather than the failure of the specified Promise. If this Promise is resolved with a failure and the failure is not an instance of the specified failure type, the returned Promise must be failed with the failure of this Promise. 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() 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.
| |
| onFailure | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Register a callback to be called with the failure for this Promise when this Promise is resolved with a failure. The callback will not be called if this Promise is resolved successfully. 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.
| |
| onFailure | back to summary |
|---|---|
| public <F> Promise Overrides org. Implements org. Doc from org. Register a callback to be called with the failure for this Promise when this Promise is resolved with a failure of a failure type. The callback will not be called if this Promise is resolved successfully or if the failure is not an instance of the specified failure type. 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.
| |
| recover | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Recover from a failure of this Promise with a recovery value. If this Promise is successfully resolved, the returned Promise must be resolved with the value of this Promise. If this Promise is resolved with a failure, the specified Function is applied to this Promise to produce a recovery value.
To recover from a failure of this Promise with a recovery value of
This method may be called at any time including before and after this Promise has been resolved.
| |
| recover | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Recover from a failure of this Promise with a recovery value if the failure is an instance of a failure type. If this Promise is successfully resolved, the returned Promise must be resolved with the value of this Promise. If this Promise is resolved with a failure and the failure is not an instance of the specified failure type, the returned Promise must be failed with the failure of this Promise. If this Promise is resolved with a failure and the failure is an instance of the specified failure type, the specified Function is applied to this Promise to produce a recovery value.
To recover from a failure of this Promise with a recovery value of
This method may be called at any time including before and after this Promise has been resolved.
| |
| recoverWith | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Recover from a failure of this Promise with a recovery Promise. If this Promise is successfully resolved, the returned Promise must be resolved with the value of this Promise. If this Promise is resolved with a failure, the specified Function is applied to this Promise to produce a recovery Promise.
This method may be called at any time including before and after this Promise has been resolved.
| |
| recoverWith | back to summary |
|---|---|
| public Promise Overrides org. Implements org. Doc from org. Recover from a failure of this Promise with a recovery Promise if the failure is an instance of a failure type. If this Promise is successfully resolved, the returned Promise must be resolved with the value of this Promise. If this Promise is resolved with a failure and the failure is not an instance of the specified failure type, the returned Promise must be failed with the failure of this Promise. If this Promise is resolved with a failure and the failure is an instance of the specified failure type, the specified Function is applied to this Promise to produce a recovery Promise.
This method may be called at any time including before and after this Promise has been resolved.
| |
| 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.
| |
| 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- | |