Class BoundedInputStream.AbstractBuilder<T extends BoundedInputStream.AbstractBuilder<T>>

Type Parameters:
T - The subclass.
All Implemented Interfaces:
IOSupplier<BoundedInputStream>
Direct Known Subclasses:
BoundedInputStream.Builder
Enclosing class:
BoundedInputStream

abstract static class BoundedInputStream.AbstractBuilder<T extends BoundedInputStream.AbstractBuilder<T>> extends ProxyInputStream.AbstractBuilder<BoundedInputStream,T>
For subclassing builders from BoundedInputStream subclassses.
  • Field Details

    • count

      private long count
      The current count of bytes counted.
    • maxCount

      private long maxCount
      The maximum count of bytes to read.
    • onMaxCount

      private IOBiConsumer<Long,Long> onMaxCount
    • propagateClose

      private boolean propagateClose
      Flag if ProxyInputStream.close() should be propagated, true by default.
  • Constructor Details

    • AbstractBuilder

      AbstractBuilder()
  • Method Details

    • getCount

      long getCount()
    • getMaxCount

      long getMaxCount()
    • getOnMaxCount

      IOBiConsumer<Long,Long> getOnMaxCount()
    • isPropagateClose

      boolean isPropagateClose()
    • setCount

      public T setCount(long count)
      Sets the current number of bytes counted.

      Useful when building from another stream to carry forward a read count.

      Default is 0, negative means 0.

      Parameters:
      count - The current number of bytes counted.
      Returns:
      this instance.
    • setMaxCount

      public T setMaxCount(long maxCount)
      Sets the maximum number of bytes to return.

      Default is -1, negative means unbound.

      Parameters:
      maxCount - The maximum number of bytes to return, negative means unbound.
      Returns:
      this instance.
    • setOnMaxCount

      public T setOnMaxCount(IOBiConsumer<Long,Long> onMaxCount)
      Sets the default BoundedInputStream.onMaxLength(long, long) behavior, null resets to a NOOP.

      The first Long is the number of bytes remaining to read before the maximum is reached count of bytes to read. The second Long is the count of bytes read.

      This does not override a BoundedInputStream subclass' implementation of the BoundedInputStream.onMaxLength(long, long) method.

      Parameters:
      onMaxCount - the ProxyInputStream.afterRead(int) behavior.
      Returns:
      this instance.
      Since:
      2.18.0
    • setPropagateClose

      public T setPropagateClose(boolean propagateClose)
      Sets whether the ProxyInputStream.close() method should propagate to the underling InputStream.

      Default is true.

      Parameters:
      propagateClose - true if calling ProxyInputStream.close() propagates to the close() method of the underlying stream or false if it does not.
      Returns:
      this instance.