Class LdapPromises


  • public final class LdapPromises
    extends Object
    Utility methods for creating and composing LdapPromises.
    • Method Detail

      • asLdapPromise

        public static <R> LdapPromise<R> asLdapPromise​(Promise<R,​LdapException> wrappedPromise)
        Converts a Promise to a LdapPromise with a request ID of -1.
        Type Parameters:
        R - The type of the task's result, or Void if the task does not return anything (i.e. it only has side-effects).
        Parameters:
        wrappedPromise - The Promise to wrap.
        Returns:
        A LdapPromise representing the same asynchronous task as the Promise provided.
      • asLdapPromise

        public static <R> LdapPromise<R> asLdapPromise​(Promise<R,​LdapException> wrappedPromise,
                                                       int requestId)
        Converts a Promise to a LdapPromise with the provided request ID.
        Type Parameters:
        R - The type of the task's result, or Void if the task does not return anything (i.e. it only has side-effects).
        Parameters:
        wrappedPromise - The Promise to wrap.
        requestId - The request ID.
        Returns:
        A LdapPromise representing the same asynchronous task as the Promise provided.
      • newFailedLdapPromise

        public static <R,​E extends LdapExceptionLdapPromise<R> newFailedLdapPromise​(E error)
        Returns a LdapPromise representing an asynchronous task which has already failed with the provided error.
        Type Parameters:
        R - The type of the task's result, or Void 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 LdapExceptionLdapPromise<R> newFailedLdapPromise​(E error,
                                                                                            int requestId)
        Returns a LdapPromise 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, or Void 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 a LdapPromise 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, or Void 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.