Class ReadStream.ReadStreamImpl<T>

java.lang.Object
io.vertx.mutiny.core.streams.ReadStream.ReadStreamImpl<T>
All Implemented Interfaces:
MutinyDelegate, ReadStream<T>, StreamBase
Enclosing interface:
ReadStream<T>

public static class ReadStream.ReadStreamImpl<T> extends Object implements ReadStream<T>
  • Field Details

    • __typeArg_0

      public final TypeArg<T> __typeArg_0
  • Constructor Details

    • ReadStreamImpl

      public ReadStreamImpl(io.vertx.core.streams.ReadStream<T> delegate)
      Create a new instance of ReadStream.ReadStreamImpl delegating to the given (non-null) instance of ReadStream.
    • ReadStreamImpl

      public ReadStreamImpl(io.vertx.core.streams.ReadStream<T> delegate, TypeArg<T> typeArg_0)
  • Method Details

    • getDelegate

      public io.vertx.core.streams.ReadStream<T> getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Specified by:
      getDelegate in interface ReadStream<T>
      Specified by:
      getDelegate in interface StreamBase
      Returns:
      the delegate instance
    • pipeTo

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<T> dst)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Specified by:
      pipeTo in interface ReadStream<T>
      Parameters:
      dst - the destination write stream
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • io.vertx.core.streams.ReadStream#pipeTo(WriteStream)
    • pipeToAndAwait

      public void pipeToAndAwait(WriteStream<T> dst)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      dst - the destination write stream
      See Also:
      • io.vertx.core.streams.ReadStream#pipeTo(WriteStream)
    • pipeToAndForget

      public ReadStream.ReadStreamImpl<T> pipeToAndForget(WriteStream<T> dst)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      dst - the destination write stream
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • io.vertx.core.streams.ReadStream#pipeTo(WriteStream)
    • exceptionHandler

      public ReadStream<T> exceptionHandler(Consumer<Throwable> handler)
      Set an exception handler on the read stream.
      Specified by:
      exceptionHandler in interface ReadStream<T>
      Specified by:
      exceptionHandler in interface StreamBase
      Parameters:
      handler - the exception handler. Can be null.
      Returns:
      a reference to this, so the API can be used fluently
    • handler

      public ReadStream.ReadStreamImpl<T> handler(Consumer<T> handler)
      Set a data handler. As data is read, the handler will be called with the data.
      Specified by:
      handler in interface ReadStream<T>
      Returns:
      a reference to this, so the API can be used fluently
    • pause

      public ReadStream.ReadStreamImpl<T> pause()
      Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

      While it's paused, no data will be sent to the data handler.

      Specified by:
      pause in interface ReadStream<T>
      Returns:
      a reference to this, so the API can be used fluently
    • resume

      public ReadStream.ReadStreamImpl<T> resume()
      Resume reading, and sets the buffer in flowing mode.

      If the ReadStream has been paused, reading will recommence on it.

      Specified by:
      resume in interface ReadStream<T>
      Returns:
      a reference to this, so the API can be used fluently
    • fetch

      public ReadStream.ReadStreamImpl<T> fetch(long amount)
      Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.
      Specified by:
      fetch in interface ReadStream<T>
      Returns:
      a reference to this, so the API can be used fluently
      Throws:
      when - the amount is a negative value
    • endHandler

      public ReadStream.ReadStreamImpl<T> endHandler(Runnable endHandler)
      Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.
      Specified by:
      endHandler in interface ReadStream<T>
      Returns:
      a reference to this, so the API can be used fluently
    • pipe

      public Pipe<T> pipe()
      Pause this stream and return a Pipe to transfer the elements of this stream to a destination WriteStream.

      The stream will be resumed when the pipe will be wired to a WriteStream.

      Specified by:
      pipe in interface ReadStream<T>
      Returns:
      a pipe