Interface LdapPromise<S>
- Type Parameters:
S
- The type of result returned by this promise.
- All Superinterfaces:
Promise<S,
LdapException>
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the request ID of the request if appropriate.<VOUT> LdapPromise<VOUT>
then
(Function<? super S, VOUT, LdapException> onResult) Submits the provided function for execution once thisPromise
has completed with a result, and returns a newPromise
representing the outcome of the function.thenAlways
(Runnable onResultOrException) Submits the provided runnable for execution once thisPromise
has completed, and regardless of whether it has a result or an exception.<VOUT> LdapPromise<VOUT>
thenAsync
(AsyncFunction<? super S, VOUT, LdapException> onResult) Submits the provided asynchronous function for execution once thisPromise
has completed with a result, and returns a newPromise
representing the outcome of the function.thenFinally
(Runnable onResultOrException) Submits the provided runnable for execution once thisPromise
has completed, and regardless of whether of its outcome.thenOnException
(ExceptionHandler<? super LdapException> onException) Registers the provided completion handler for notification if thisPromise
cannot be completed due to an exception.thenOnResult
(ResultHandler<? super S> onResult) Registers the provided completion handler for notification once thisPromise
has completed with a result.thenOnResultOrException
(Runnable onResultOrException) Submits the provided runnable for execution once thisPromise
has completed, and regardless of whether it has a result or an exception.thenOnResultOrException
(ResultHandler<? super S> onResult, ExceptionHandler<? super LdapException> onException) Registers the provided completion handlers for notification once thisPromise
has completed (with a result or an exception).Methods inherited from interface org.forgerock.util.promise.Promise
cancel, get, get, getOrThrow, getOrThrow, getOrThrowIfInterrupted, getOrThrowUninterruptibly, getOrThrowUninterruptibly, isCancelled, isDone, isResult, then, then, thenAsync, thenAsync, thenCatch, thenCatchAsync, thenCatchRuntimeException, thenCatchRuntimeExceptionAsync, thenDiscardResult, thenOnCompletion, thenOnRuntimeException
-
Method Details
-
getRequestId
int getRequestId()Returns the request ID of the request if appropriate.- Returns:
- The request ID, or
-1
if there is no request ID.
-
thenOnResult
Description copied from interface:Promise
Registers the provided completion handler for notification once thisPromise
has completed with a result. If thisPromise
completes with an exception then the completion handler will not be notified.This method can be used for asynchronous completion notification and is equivalent to
Promise.then(Function)
.- Specified by:
thenOnResult
in interfacePromise<S,
LdapException> - Parameters:
onResult
- The completion handler which will be notified upon successful completion of thisPromise
.- Returns:
- A
Promise
that is guaranteed to be completed once the provided callback has been executed.
-
thenOnException
Description copied from interface:Promise
Registers the provided completion handler for notification if thisPromise
cannot be completed due to an exception. If thisPromise
completes with a result then the completion handler will not be notified.This method can be used for asynchronous completion notification.
- Specified by:
thenOnException
in interfacePromise<S,
LdapException> - Parameters:
onException
- The completion handler which will be notified upon failure completion of thisPromise
.- Returns:
- A
Promise
that is guaranteed to be completed once the provided callback has been executed.
-
thenOnResultOrException
Description copied from interface:Promise
Submits the provided runnable for execution once thisPromise
has completed, and regardless of whether it has a result or an exception.This method can be used for resource cleanup after a series of asynchronous tasks have completed. More specifically, this method should be used in a similar manner to
finally
statements intry...catch
expressions.This method is equivalent to
Promise.thenAlways(Runnable)
.- Specified by:
thenOnResultOrException
in interfacePromise<S,
LdapException> - Parameters:
onResultOrException
- The runnable which will be notified regardless of the final outcome of thisPromise
.- Returns:
- A
Promise
that is guaranteed to be completed once the provided callback has been executed.
-
then
Description copied from interface:Promise
Submits the provided function for execution once thisPromise
has completed with a result, and returns a newPromise
representing the outcome of the function. If thisPromise
does not complete with a result then the function will not be invoked and the exception will be forwarded to the returnedPromise
.This method can be used for transforming the result of an asynchronous task.
- Specified by:
then
in interfacePromise<S,
LdapException> - Type Parameters:
VOUT
- The type of the function's result, orVoid
if the function does not return anything (i.e. it only has side-effects). Note that the type may be different to the type of thisPromise
.- Parameters:
onResult
- The function which will be executed upon successful completion of thisPromise
.- Returns:
- A new
Promise
representing the outcome of the function.
-
thenOnResultOrException
LdapPromise<S> thenOnResultOrException(ResultHandler<? super S> onResult, ExceptionHandler<? super LdapException> onException) Description copied from interface:Promise
Registers the provided completion handlers for notification once thisPromise
has completed (with a result or an exception). If thisPromise
completes with a result thenonResult
will be notified with the result, otherwiseonException
will be notified with the exception that occurred.This method can be used for asynchronous completion notification.
- Specified by:
thenOnResultOrException
in interfacePromise<S,
LdapException> - Parameters:
onResult
- The completion handler which will be notified upon completion with a result of thisPromise
.onException
- The completion handler which will be notified upon failure of thisPromise
.- Returns:
- A
Promise
that is guaranted to be completed once the provided callback has been executed.
-
thenAlways
Description copied from interface:Promise
Submits the provided runnable for execution once thisPromise
has completed, and regardless of whether it has a result or an exception.This method can be used for resource cleanup after a series of asynchronous tasks have completed. More specifically, this method should be used in a similar manner to
finally
statements intry...catch
expressions.This method is equivalent to
Promise.thenOnResultOrException(Runnable)
.- Specified by:
thenAlways
in interfacePromise<S,
LdapException> - Parameters:
onResultOrException
- The runnable which will be notified regardless of the final outcome of thisPromise
.- Returns:
- A
Promise
that is guaranteed to be completed once the provided callback has been executed.
-
thenFinally
Description copied from interface:Promise
Submits the provided runnable for execution once thisPromise
has completed, and regardless of whether of its outcome.This method can be used for resource cleanup after a series of asynchronous tasks have completed. More specifically, this method should be used in a similar manner to
finally
statements intry...catch
expressions.This method is equivalent to
Promise.thenAlways(Runnable)
.- Specified by:
thenFinally
in interfacePromise<S,
LdapException> - Parameters:
onResultOrException
- The runnable which will be notified regardless of the final outcome of thisPromise
.- Returns:
- A
Promise
that is guaranteed to be completed once the provided callback has been executed.
-
thenAsync
Description copied from interface:Promise
Submits the provided asynchronous function for execution once thisPromise
has completed with a result, and returns a newPromise
representing the outcome of the function. If thisPromise
complete with an exception then the function will not be invoked and the error will be forwarded to the returnedPromise
.This method may be used for chaining together a series of asynchronous tasks.
- Specified by:
thenAsync
in interfacePromise<S,
LdapException> - Type Parameters:
VOUT
- The type of the function's result, orVoid
if the function does not return anything (i.e. it only has side-effects). Note that the type may be different to the type of thisPromise
.- Parameters:
onResult
- The asynchronous function which will be executed upon successful completion of thisPromise
.- Returns:
- A new
Promise
representing the outcome of the function.
-