Interface LdapPromise<S>
-
- Type Parameters:
S- The type of result returned by this promise.
- All Superinterfaces:
Promise<S,LdapException>
public interface LdapPromise<S> extends Promise<S,LdapException>
A handle which can be used to retrieve the Result of an asynchronous Request.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetRequestId()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 thisPromisehas completed with a result, and returns a newPromiserepresenting the outcome of the function.LdapPromise<S>thenAlways(Runnable onResultOrException)Submits the provided runnable for execution once thisPromisehas 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 thisPromisehas completed with a result, and returns a newPromiserepresenting the outcome of the function.LdapPromise<S>thenFinally(Runnable onResultOrException)Submits the provided runnable for execution once thisPromisehas completed, and regardless of whether of its outcome.LdapPromise<S>thenOnException(ExceptionHandler<? super LdapException> onException)Registers the provided completion handler for notification if thisPromisecannot be completed due to an exception.LdapPromise<S>thenOnResult(ResultHandler<? super S> onResult)Registers the provided completion handler for notification once thisPromisehas completed with a result.LdapPromise<S>thenOnResultOrException(Runnable onResultOrException)Submits the provided runnable for execution once thisPromisehas completed, and regardless of whether it has a result or an exception.LdapPromise<S>thenOnResultOrException(ResultHandler<? super S> onResult, ExceptionHandler<? super LdapException> onException)Registers the provided completion handlers for notification once thisPromisehas 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 Detail
-
getRequestId
int getRequestId()
Returns the request ID of the request if appropriate.- Returns:
- The request ID, or
-1if there is no request ID.
-
thenOnResult
LdapPromise<S> thenOnResult(ResultHandler<? super S> onResult)
Description copied from interface:PromiseRegisters the provided completion handler for notification once thisPromisehas completed with a result. If thisPromisecompletes 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:
thenOnResultin interfacePromise<S,LdapException>- Parameters:
onResult- The completion handler which will be notified upon successful completion of thisPromise.- Returns:
- A
Promisethat is guaranteed to be completed once the provided callback has been executed.
-
thenOnException
LdapPromise<S> thenOnException(ExceptionHandler<? super LdapException> onException)
Description copied from interface:PromiseRegisters the provided completion handler for notification if thisPromisecannot be completed due to an exception. If thisPromisecompletes with a result then the completion handler will not be notified.This method can be used for asynchronous completion notification.
- Specified by:
thenOnExceptionin interfacePromise<S,LdapException>- Parameters:
onException- The completion handler which will be notified upon failure completion of thisPromise.- Returns:
- A
Promisethat is guaranteed to be completed once the provided callback has been executed.
-
thenOnResultOrException
LdapPromise<S> thenOnResultOrException(Runnable onResultOrException)
Description copied from interface:PromiseSubmits the provided runnable for execution once thisPromisehas 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
finallystatements intry...catchexpressions.This method is equivalent to
Promise.thenAlways(Runnable).- Specified by:
thenOnResultOrExceptionin interfacePromise<S,LdapException>- Parameters:
onResultOrException- The runnable which will be notified regardless of the final outcome of thisPromise.- Returns:
- A
Promisethat is guaranteed to be completed once the provided callback has been executed.
-
then
<VOUT> LdapPromise<VOUT> then(Function<? super S,VOUT,LdapException> onResult)
Description copied from interface:PromiseSubmits the provided function for execution once thisPromisehas completed with a result, and returns a newPromiserepresenting the outcome of the function. If thisPromisedoes 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:
thenin interfacePromise<S,LdapException>- Type Parameters:
VOUT- The type of the function's result, orVoidif 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
Promiserepresenting the outcome of the function.
-
thenOnResultOrException
LdapPromise<S> thenOnResultOrException(ResultHandler<? super S> onResult, ExceptionHandler<? super LdapException> onException)
Description copied from interface:PromiseRegisters the provided completion handlers for notification once thisPromisehas completed (with a result or an exception). If thisPromisecompletes with a result thenonResultwill be notified with the result, otherwiseonExceptionwill be notified with the exception that occurred.This method can be used for asynchronous completion notification.
- Specified by:
thenOnResultOrExceptionin 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
Promisethat is guaranted to be completed once the provided callback has been executed.
-
thenAlways
LdapPromise<S> thenAlways(Runnable onResultOrException)
Description copied from interface:PromiseSubmits the provided runnable for execution once thisPromisehas 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
finallystatements intry...catchexpressions.This method is equivalent to
Promise.thenOnResultOrException(Runnable).- Specified by:
thenAlwaysin interfacePromise<S,LdapException>- Parameters:
onResultOrException- The runnable which will be notified regardless of the final outcome of thisPromise.- Returns:
- A
Promisethat is guaranteed to be completed once the provided callback has been executed.
-
thenFinally
LdapPromise<S> thenFinally(Runnable onResultOrException)
Description copied from interface:PromiseSubmits the provided runnable for execution once thisPromisehas 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
finallystatements intry...catchexpressions.This method is equivalent to
Promise.thenAlways(Runnable).- Specified by:
thenFinallyin interfacePromise<S,LdapException>- Parameters:
onResultOrException- The runnable which will be notified regardless of the final outcome of thisPromise.- Returns:
- A
Promisethat is guaranteed to be completed once the provided callback has been executed.
-
thenAsync
<VOUT> LdapPromise<VOUT> thenAsync(AsyncFunction<? super S,VOUT,LdapException> onResult)
Description copied from interface:PromiseSubmits the provided asynchronous function for execution once thisPromisehas completed with a result, and returns a newPromiserepresenting the outcome of the function. If thisPromisecomplete 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:
thenAsyncin interfacePromise<S,LdapException>- Type Parameters:
VOUT- The type of the function's result, orVoidif 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
Promiserepresenting the outcome of the function.
-
-