Class BaseStreamWrapper<T,S extends BaseStream<T,S>>

java.lang.Object
org.apache.sis.internal.stream.BaseStreamWrapper<T,S>
Type Parameters:
T - type of values contained in the stream, as defined in BaseStream.
S - type of stream interface, as defined in BaseStream.
All Implemented Interfaces:
AutoCloseable, BaseStream<T,S>
Direct Known Subclasses:
DoubleStreamWrapper, StreamWrapper

public abstract class BaseStreamWrapper<T,S extends BaseStream<T,S>> extends Object implements BaseStream<T,S>
Base class of all stream wrappers defined in this package.
Since:
1.1
Version:
1.1
  • Field Details

    • toClose

      S extends BaseStream<T,S> toClose
      The stream to close, or null if none. This is set at construction time (typically to the same stream than the source) and should not be modified after that point.
  • Constructor Details

    • BaseStreamWrapper

      BaseStreamWrapper()
      For sub-classes constructors.
    • BaseStreamWrapper

      protected BaseStreamWrapper(S source)
      Creates a new wrapper for the given stream.
      Parameters:
      source - the stream to wrap.
  • Method Details

    • source

      abstract S source()
      Verifies that this stream is still the active one, then returns the source of this stream.
      Returns:
      the stream containing actual data.
      Throws:
      IllegalStateException - if this stream is no longer the active stream on which to apply operations.
    • inactive

      final IllegalStateException inactive()
      Returns the exception to throw when an operation is invoked on an inactive stream.
    • isParallel

      public boolean isParallel()
      Returns whether stream terminal operation would execute in parallel.
      Specified by:
      isParallel in interface BaseStream<T,S extends BaseStream<T,S>>
      Returns:
      whether this stream works in parallel.
    • close

      public void close()
      Closes this stream. This method can be invoked on this stream even if it is not anymore the active one because this is the stream referenced in a try ... finally block.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface BaseStream<T,S extends BaseStream<T,S>>