Package org.forgerock.opendj.ldap.spi
Class LdapPromises
- java.lang.Object
-
- org.forgerock.opendj.ldap.spi.LdapPromises
-
public final class LdapPromises extends Object
Utility methods for creating and composingLdapPromise
s.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <R> LdapPromise<R>
asLdapPromise(Promise<R,LdapException> wrappedPromise)
Converts aPromise
to aLdapPromise
with a request ID of -1.static <R> LdapPromise<R>
asLdapPromise(Promise<R,LdapException> wrappedPromise, int requestId)
Converts aPromise
to aLdapPromise
with the provided request ID.static <R,E extends LdapException>
LdapPromise<R>newFailedLdapPromise(E error)
Returns aLdapPromise
representing an asynchronous task which has already failed with the provided error.static <R,E extends LdapException>
LdapPromise<R>newFailedLdapPromise(E error, int requestId)
Returns aLdapPromise
representing an asynchronous task, identified by the provided requestId, which has already failed with the provided error.static <R> LdapPromise<R>
newSuccessfulLdapPromise(R result)
Returns aLdapPromise
representing an asynchronous task which has already succeeded with the provided result.
-
-
-
Method Detail
-
asLdapPromise
public static <R> LdapPromise<R> asLdapPromise(Promise<R,LdapException> wrappedPromise)
Converts aPromise
to aLdapPromise
with a request ID of -1.- Type Parameters:
R
- The type of the task's result, orVoid
if the task does not return anything (i.e. it only has side-effects).- Parameters:
wrappedPromise
- ThePromise
to wrap.- Returns:
- A
LdapPromise
representing the same asynchronous task as thePromise
provided.
-
asLdapPromise
public static <R> LdapPromise<R> asLdapPromise(Promise<R,LdapException> wrappedPromise, int requestId)
Converts aPromise
to aLdapPromise
with the provided request ID.- Type Parameters:
R
- The type of the task's result, orVoid
if the task does not return anything (i.e. it only has side-effects).- Parameters:
wrappedPromise
- ThePromise
to wrap.requestId
- The request ID.- Returns:
- A
LdapPromise
representing the same asynchronous task as thePromise
provided.
-
newFailedLdapPromise
public static <R,E extends LdapException> LdapPromise<R> newFailedLdapPromise(E error)
Returns aLdapPromise
representing an asynchronous task which has already failed with the provided error.- Type Parameters:
R
- The type of the task's result, orVoid
if the task does not return anything (i.e. it only has side-effects).E
- The type of the exception thrown by the task if it fails.- Parameters:
error
- The exception indicating why the asynchronous task has failed.- Returns:
- A
LdapPromise
representing an asynchronous task which has already failed with the provided error.
-
newFailedLdapPromise
public static <R,E extends LdapException> LdapPromise<R> newFailedLdapPromise(E error, int requestId)
Returns aLdapPromise
representing an asynchronous task, identified by the provided requestId, which has already failed with the provided error.- Type Parameters:
R
- The type of the task's result, orVoid
if the task does not return anything (i.e. it only has side-effects).E
- The type of the exception thrown by the task if it fails.- Parameters:
error
- The exception indicating why the asynchronous task has failed.requestId
- The request ID of the failed task.- Returns:
- A
LdapPromise
representing an asynchronous task which has already failed with the provided error.
-
newSuccessfulLdapPromise
public static <R> LdapPromise<R> newSuccessfulLdapPromise(R result)
Returns aLdapPromise
representing an asynchronous task which has already succeeded with the provided result. Attempts to get the result will immediately return the result.- Type Parameters:
R
- The type of the task's result, orVoid
if the task does not return anything (i.e. it only has side-effects).- Parameters:
result
- The result of the asynchronous task.- Returns:
- A
LdapPromise
representing an asynchronous task which has already succeeded with the provided result.
-
-