Class CompletableContext<T>

  • Type Parameters:
    T - the result type

    public class CompletableContext<T>
    extends java.lang.Object
    A thread-safe completable context that allows listeners to be attached. This class relies on the CompletableFuture for the concurrency logic. However, it does not accept Throwable as an exceptional result. This allows attaching listeners that only handle Exception.
    • Method Summary

      Modifier and Type Method Description
      void addListener​(java.util.function.BiConsumer<T,​? super java.lang.Exception> listener)  
      boolean complete​(T value)  
      boolean completeExceptionally​(java.lang.Exception ex)  
      boolean isCompletedExceptionally()  
      boolean isDone()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CompletableContext

        public CompletableContext()
    • Method Detail

      • addListener

        public void addListener​(java.util.function.BiConsumer<T,​? super java.lang.Exception> listener)
      • isDone

        public boolean isDone()
      • isCompletedExceptionally

        public boolean isCompletedExceptionally()
      • completeExceptionally

        public boolean completeExceptionally​(java.lang.Exception ex)
      • complete

        public boolean complete​(T value)