Class LdapPromiseImpl<S>

java.lang.Object
org.forgerock.opendj.ldap.spi.LdapPromiseImpl<S>
Type Parameters:
S - The type of result returned by this promise.
All Implemented Interfaces:
Future<S>, LdapPromise<S>, LdapResultHandler<S>, org.forgerock.util.promise.ExceptionHandler<LdapException>, org.forgerock.util.promise.Promise<S,LdapException>, org.forgerock.util.promise.ResultHandler<S>
Direct Known Subclasses:
ResultLdapPromiseImpl

public class LdapPromiseImpl<S> extends Object implements LdapPromise<S>, LdapResultHandler<S>
This class provides an implementation of the LdapPromise.
See Also:
  • Constructor Details

    • LdapPromiseImpl

      protected LdapPromiseImpl(org.forgerock.util.promise.PromiseImpl<S,LdapException> wrappedPromise, int requestID)
      Creates a new LdapPromiseImpl from a wrapped existing PromiseImpl.
      Parameters:
      wrappedPromise - The Promise to wrap.
      requestID - Identifier of the request.
  • Method Details

    • newLdapPromiseImpl

      public static <S> LdapPromiseImpl<S> newLdapPromiseImpl()
      Creates a new LdapPromiseImpl.
      Type Parameters:
      S - The type of result of the promise.
      Returns:
      a new LdapPromiseImpl
    • newLdapPromiseImpl

      public static <S> LdapPromiseImpl<S> newLdapPromiseImpl(int requestID)
      Creates a new LdapPromiseImpl with a requestID.
      Type Parameters:
      S - The type of result of the promise.
      Parameters:
      requestID - Identifier of the request.
      Returns:
      a new LdapPromiseImpl
    • handleException

      public void handleException(LdapException exception)
      Description copied from interface: LdapResultHandler
      Invoked when the asynchronous operation has failed.
      Specified by:
      handleException in interface org.forgerock.util.promise.ExceptionHandler<S>
      Specified by:
      handleException in interface LdapResultHandler<S>
      Parameters:
      exception - The error result exception indicating why the asynchronous operation has failed.
    • handleResult

      public void handleResult(S result)
      Description copied from interface: LdapResultHandler
      Invoked when the asynchronous operation has completed successfully.
      Specified by:
      handleResult in interface LdapResultHandler<S>
      Specified by:
      handleResult in interface org.forgerock.util.promise.ResultHandler<S>
      Parameters:
      result - The result of the asynchronous operation.
    • getRequestID

      public int getRequestID()
      Description copied from interface: LdapPromise
      Returns the request ID of the request if appropriate.
      Specified by:
      getRequestID in interface LdapPromise<R>
      Returns:
      The request ID, or -1 if there is no request ID.
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      Specified by:
      cancel in interface Future<R>
      Specified by:
      cancel in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • get

      Specified by:
      get in interface Future<R>
      Specified by:
      get in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      ExecutionException
      InterruptedException
    • get

      public S get(long timeout, TimeUnit unit) throws ExecutionException, TimeoutException, InterruptedException
      Specified by:
      get in interface Future<R>
      Specified by:
      get in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      ExecutionException
      TimeoutException
      InterruptedException
    • getOrThrow

      public S getOrThrow() throws InterruptedException, LdapException
      Specified by:
      getOrThrow in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      InterruptedException
      LdapException
    • getOrThrow

      public S getOrThrow(long timeout, TimeUnit unit) throws InterruptedException, LdapException, TimeoutException
      Specified by:
      getOrThrow in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      InterruptedException
      LdapException
      TimeoutException
    • getOrThrowUninterruptibly

      public S getOrThrowUninterruptibly() throws LdapException
      Specified by:
      getOrThrowUninterruptibly in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      LdapException
    • getOrThrowUninterruptibly

      public S getOrThrowUninterruptibly(long timeout, TimeUnit unit) throws LdapException, TimeoutException
      Specified by:
      getOrThrowUninterruptibly in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      LdapException
      TimeoutException
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Future<R>
      Specified by:
      isCancelled in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface Future<R>
      Specified by:
      isDone in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnException

      public LdapPromise<S> thenOnException(org.forgerock.util.promise.ExceptionHandler<? super LdapException> onException)
      Specified by:
      thenOnException in interface LdapPromise<R>
      Specified by:
      thenOnException in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnRuntimeException

      public LdapPromise<S> thenOnRuntimeException(org.forgerock.util.promise.RuntimeExceptionHandler onRuntimeException)
      Specified by:
      thenOnRuntimeException in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnResult

      public LdapPromise<S> thenOnResult(org.forgerock.util.promise.ResultHandler<? super S> onResult)
      Specified by:
      thenOnResult in interface LdapPromise<R>
      Specified by:
      thenOnResult in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnResultOrException

      public LdapPromise<S> thenOnResultOrException(Runnable onResultOrException)
      Specified by:
      thenOnResultOrException in interface LdapPromise<R>
      Specified by:
      thenOnResultOrException in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • then

      public <VOUT> LdapPromise<VOUT> then(org.forgerock.util.Function<? super S,VOUT,LdapException> onResult)
      Specified by:
      then in interface LdapPromise<R>
      Specified by:
      then in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • then

      public <VOUT, EOUT extends Exception> org.forgerock.util.promise.Promise<VOUT,EOUT> then(org.forgerock.util.Function<? super S,VOUT,EOUT> onResult, org.forgerock.util.Function<? super LdapException,VOUT,EOUT> onException)
      Specified by:
      then in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • then

      public <VOUT, EOUT extends Exception> org.forgerock.util.promise.Promise<VOUT,EOUT> then(org.forgerock.util.Function<? super S,VOUT,EOUT> onResult, org.forgerock.util.Function<? super LdapException,VOUT,EOUT> onException, org.forgerock.util.Function<? super RuntimeException,VOUT,EOUT> onRuntimeException)
      Specified by:
      then in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnResultOrException

      public LdapPromise<S> thenOnResultOrException(org.forgerock.util.promise.ResultHandler<? super S> onResult, org.forgerock.util.promise.ExceptionHandler<? super LdapException> onException)
      Specified by:
      thenOnResultOrException in interface LdapPromise<R>
      Specified by:
      thenOnResultOrException in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenAlways

      public LdapPromise<S> thenAlways(Runnable onResultOrException)
      Specified by:
      thenAlways in interface LdapPromise<R>
      Specified by:
      thenAlways in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenAsync

      public <VOUT> LdapPromise<VOUT> thenAsync(org.forgerock.util.AsyncFunction<? super S,VOUT,LdapException> onResult)
      Specified by:
      thenAsync in interface LdapPromise<R>
      Specified by:
      thenAsync in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenAsync

      public <VOUT, EOUT extends Exception> org.forgerock.util.promise.Promise<VOUT,EOUT> thenAsync(org.forgerock.util.AsyncFunction<? super S,VOUT,EOUT> onResult, org.forgerock.util.AsyncFunction<? super LdapException,VOUT,EOUT> onException)
      Specified by:
      thenAsync in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenAsync

      public <VOUT, EOUT extends Exception> org.forgerock.util.promise.Promise<VOUT,EOUT> thenAsync(org.forgerock.util.AsyncFunction<? super S,VOUT,EOUT> onResult, org.forgerock.util.AsyncFunction<? super LdapException,VOUT,EOUT> onException, org.forgerock.util.AsyncFunction<? super RuntimeException,VOUT,EOUT> onRuntimeException)
      Specified by:
      thenAsync in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenCatch

      public <EOUT extends Exception> org.forgerock.util.promise.Promise<S,EOUT> thenCatch(org.forgerock.util.Function<? super LdapException,S,EOUT> onException)
      Specified by:
      thenCatch in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenCatchRuntimeException

      public org.forgerock.util.promise.Promise<S,LdapException> thenCatchRuntimeException(org.forgerock.util.Function<? super RuntimeException,S,LdapException> onRuntimeException)
      Specified by:
      thenCatchRuntimeException in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenCatchRuntimeExceptionAsync

      public org.forgerock.util.promise.Promise<S,LdapException> thenCatchRuntimeExceptionAsync(org.forgerock.util.AsyncFunction<? super RuntimeException,S,LdapException> onRuntimeException)
      Specified by:
      thenCatchRuntimeExceptionAsync in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenFinally

      public LdapPromise<S> thenFinally(Runnable onResultOrException)
      Specified by:
      thenFinally in interface LdapPromise<R>
      Specified by:
      thenFinally in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenCatchAsync

      public <EOUT extends Exception> org.forgerock.util.promise.Promise<S,EOUT> thenCatchAsync(org.forgerock.util.AsyncFunction<? super LdapException,S,EOUT> onException)
      Specified by:
      thenCatchAsync in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • getWrappedPromise

      public org.forgerock.util.promise.PromiseImpl<S,LdapException> getWrappedPromise()