This class is not used directly by clients. Clients should use
PromiseFactory to create a Promise.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static interface | PromiseImpl.
Marker interface for internal callbacks which do not call user code and should be run on the current thread for an already resolved promise. |
| private class | |
| private class | PromiseImpl.
A callback used for the |
| pack-priv static interface | |
| private class | PromiseImpl.
A callback used for the |
| Modifier and Type | Field and Description |
|---|---|
| private final ConcurrentLinkedQueue | callbacks
A ConcurrentLinkedQueue to hold the callbacks for this Promise, so no additional synchronization is required to write to or read from the queue. |
| private final PromiseFactory | factory
The factory to use for callbacks and scheduled operations. |
| Access | Constructor and Description |
|---|---|
| pack-priv | PromiseImpl(PromiseFactory
The factory to use for callbacks and scheduled
operations. factory)Initialize this Promise. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv <V> DeferredPromiseImpl | Returns: A new DeferredPromiseImpl.Return a new |
| public Promise | delay(long
The time to delay in milliseconds. Zero and negative
time is treated as no delay. millis)Implements org. Delay after the resolution of this Promise. |
| pack-priv void | |
| pack-priv <V> FailedPromiseImpl | Returns: A new FailedPromiseImpl.Failure for the FailedPromiseImpl. f)Return a new |
| 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.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.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 Promise | filter(Predicate<? super T>
The Predicate to evaluate the value of this Promise.
Must not be predicate)null.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.Implements org. FlatMap the value of this Promise. |
| 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.Implements org. Map the value of this Promise. |
| pack-priv void | |
| public Promise | onFailure(Consumer<? super Throwable>
The Consumer callback that receives the failure of this
Promise. Must not be failure)null.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.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 | onResolve(Runnable
The callback to be called when this Promise is resolved.
Must not be callback)null.Implements org. Register a callback to be called when this Promise is resolved. |
| public Promise | onSuccess(Consumer<? super T>
The Consumer callback that receives the value of this
Promise. Must not be success)null.Implements org. Register a callback to be called with the result of this Promise when this Promise is resolved successfully. |
| 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.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.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.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.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 <V> ResolvedPromiseImpl | Returns: A new ResolvedPromiseImpl.Value for the ResolvedPromiseImpl. v)Return a new |
| pack-priv abstract void | |
| pack-priv static <R> void | result(Promise<? extends R> promise, PromiseImpl.
Accept the result of the specified Promise. |
| pack-priv ScheduledFuture | |
| 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.Implements org. Chain a new Promise to this Promise with Success and Failure callbacks. |
| public <R> Promise | then(Success<? super T, ? extends R>
The Success callback to be called when this Promise is
successfully resolved. May be success)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.Implements org. Chain a new Promise to this Promise with a Success callback. |
| public Promise | thenAccept(Consumer<? super T>
The Consumer callback that receives the value of this
Promise. Must not be consumer)null.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)Implements org. Time out the resolution of this Promise. |
| public CompletionStage | toCompletionStage()
Implements org. Returns a new CompletionStage that will be resolved with the result of this Promise. |
| pack-priv static void |