Package org.apache.sis.internal.stream
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 inBaseStream
.S
- type of stream interface, as defined inBaseStream
.
- 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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
For sub-classes constructors.protected
BaseStreamWrapper
(S source) Creates a new wrapper for the given stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this stream.(package private) final IllegalStateException
inactive()
Returns the exception to throw when an operation is invoked on an inactive stream.boolean
Returns whether stream terminal operation would execute in parallel.(package private) abstract S
source()
Verifies that this stream is still the active one, then returns the source of this stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.stream.BaseStream
iterator, onClose, parallel, sequential, spliterator, unordered
-
Field Details
-
toClose
S extends BaseStream<T,S> toCloseThe stream to close, ornull
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
Creates a new wrapper for the given stream.- Parameters:
source
- the stream to wrap.
-
-
Method Details
-
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
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 interfaceBaseStream<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 atry ... finally
block.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceBaseStream<T,
S extends BaseStream<T, S>>
-