Package ratpack.exec

Interface Downstream<T>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void accept​(com.google.common.util.concurrent.ListenableFuture<? extends T> future)
      Sends the result of the future downstream.
      default void accept​(java.util.concurrent.CompletionStage<? extends T> completionStage)
      Sends the result of a CompletionStage downstream.
      default void accept​(ExecResult<? extends T> result)
      Signals this downstream, based on the given result.
      default void accept​(Result<? extends T> result)
      Signals this downstream, based on the given result.
      default Downstream<T> closing​(java.lang.AutoCloseable closeable)
      Creates a decorated downstream that closes the given closeable for each signal type.
      default Downstream<T> closing​(Operation closer)
      Like closing(AutoCloseable), but allows async close operations.
      void complete()
      Signals that the upstream will not be providing a value, as it has terminated.
      default <I extends T,​A>
      java.nio.channels.CompletionHandler<I,​A>
      completionHandler()
      Creates a JDK CompletionHandler that connects to this downstream.
      default Downstream<T> consumeErrorIf​(Predicate<? super java.lang.Throwable> predicate, Action<? super java.lang.Throwable> errorHandler)  
      void error​(java.lang.Throwable throwable)
      Signals the unsuccessful production of the upstream value.
      default Downstream<T> onComplete​(Block block)
      Wrap this downstream, using the given action as the implementation of the complete() method.
      default Downstream<T> onError​(Action<? super java.lang.Throwable> action)
      Wrap this downstream, using the given action as the implementation of the error(Throwable) method.
      default <O> Downstream<O> onSuccess​(Action<? super O> action)
      Wrap this downstream, using the given action as the implementation of the success(T) method.
      void success​(T value)
      Signals the successful production of the upstream value.
    • Method Detail

      • success

        void success​(T value)
        Signals the successful production of the upstream value.
        Parameters:
        value - the upstream value
      • error

        void error​(java.lang.Throwable throwable)
        Signals the unsuccessful production of the upstream value.
        Parameters:
        throwable - what went wrong
      • complete

        void complete()
        Signals that the upstream will not be providing a value, as it has terminated.
      • onSuccess

        default <O> Downstream<O> onSuccess​(Action<? super O> action)
        Wrap this downstream, using the given action as the implementation of the success(T) method.

        All error(java.lang.Throwable) and complete() signals will be forwarded to this downstream, and the given action called with the value if success(T) is signalled.

        Type Parameters:
        O - the type of item accepted
        Parameters:
        action - the implementation of the success signal receiver for the returned downstream
        Returns:
        a downstream
      • onError

        default Downstream<T> onError​(Action<? super java.lang.Throwable> action)
        Wrap this downstream, using the given action as the implementation of the error(Throwable) method.

        All success(T) and complete() signals will be forwarded to this downstream, and the given action called with the value if success(T) is signalled.

        Parameters:
        action - the implementation of the error signal receiver for the returned downstream
        Returns:
        a downstream
      • consumeErrorIf

        default Downstream<T> consumeErrorIf​(Predicate<? super java.lang.Throwable> predicate,
                                             Action<? super java.lang.Throwable> errorHandler)
      • onComplete

        default Downstream<T> onComplete​(Block block)
        Wrap this downstream, using the given action as the implementation of the complete() method.

        All success(T) and error(java.lang.Throwable) signals will be forwarded to this downstream, and the given action called with the value if complete() is signalled.

        Parameters:
        block - the implementation of the complete signal receiver for the returned downstream
        Returns:
        a downstream
      • accept

        default void accept​(ExecResult<? extends T> result)
        Signals this downstream, based on the given result.
        Parameters:
        result - the result to signal
      • accept

        default void accept​(Result<? extends T> result)
        Signals this downstream, based on the given result.
        Parameters:
        result - the result to signal
      • accept

        default void accept​(java.util.concurrent.CompletionStage<? extends T> completionStage)
        Sends the result of a CompletionStage downstream.
        Parameters:
        completionStage - the CompletionStage to consume the value of
      • accept

        default void accept​(com.google.common.util.concurrent.ListenableFuture<? extends T> future)
        Sends the result of the future downstream.
        Parameters:
        future - the future to consume the value of
      • completionHandler

        default <I extends T,​A> java.nio.channels.CompletionHandler<I,​A> completionHandler()
        Creates a JDK CompletionHandler that connects to this downstream.
        Returns:
        a completion handler
        Since:
        1.2
      • closing

        default Downstream<T> closing​(java.lang.AutoCloseable closeable)
        Creates a decorated downstream that closes the given closeable for each signal type.

        This can be used to simulate a try/finally synchronous construct.

        Parameters:
        closeable - the closeable to close
        Returns:
        a decorated downstream
        Since:
        1.10
        See Also:
        closing(Operation)
      • closing

        default Downstream<T> closing​(Operation closer)
        Like closing(AutoCloseable), but allows async close operations.
        Parameters:
        closer - the close operation.
        Returns:
        a decorated downstream
        Since:
        1.5