Package org.apache.sis.internal.stream
Class PaginedStream<T>
java.lang.Object
org.apache.sis.internal.stream.BaseStreamWrapper<T,Stream<T>>
org.apache.sis.internal.stream.StreamWrapper<T>
org.apache.sis.internal.stream.PaginedStream<T>
- Type Parameters:
T
- the type of objects contained in the stream, as specified inStream
interface.
- All Implemented Interfaces:
AutoCloseable
,BaseStream<T,
,Stream<T>> Stream<T>
A stream on which
skip
and limit
operations are delegated to a root stream.
This is useful when the root stream is capable of some optimizations, for example using SQL.
The redirection stops as soon as an operation may change the elements order or filtering.- Since:
- 1.1
- Version:
- 1.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.stream.Stream
Stream.Builder<T extends Object>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stream<?>
The root stream on which to delegateskip
andlimit
operations.Fields inherited from class org.apache.sis.internal.stream.StreamWrapper
source
Fields inherited from class org.apache.sis.internal.stream.BaseStreamWrapper
toClose
-
Constructor Summary
ConstructorsConstructorDescriptionPaginedStream
(Stream<T> source, Stream<?> root) Creates a new mapped stream. -
Method Summary
Modifier and TypeMethodDescriptionlong
count()
Returns the number of elements in this stream.distinct()
Returns a stream with distinct elements of this stream.Returns a stream with elements of this stream that match the given predicate.limit
(long maxSize) Truncates this stream to the given number of elements.mapToDouble
(ToDoubleFunction<? super T> mapper) Returns a stream with results of applying the given function to the elements of this stream.skip
(long n) Discards the specified number of elements.sorted()
Returns a stream with elements of this stream sorted in natural order.sorted
(Comparator<? super T> comparator) Returns a stream with elements of this stream sorted using the given comparator.Returns an equivalent stream that is unordered.Methods inherited from class org.apache.sis.internal.stream.StreamWrapper
allMatch, anyMatch, collect, collect, delegate, findAny, findFirst, flatMap, flatMapToDouble, flatMapToInt, flatMapToLong, forEach, forEachOrdered, iterator, map, mapToInt, mapToLong, max, min, noneMatch, onClose, parallel, peek, reduce, reduce, reduce, sequential, source, spliterator, toArray, toArray
Methods inherited from class org.apache.sis.internal.stream.BaseStreamWrapper
close, inactive, isParallel
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
close, isParallel
Methods inherited from interface java.util.stream.Stream
dropWhile, mapMulti, mapMultiToDouble, mapMultiToInt, mapMultiToLong, takeWhile, toList
-
Field Details
-
root
The root stream on which to delegateskip
andlimit
operations.
-
-
Constructor Details
-
PaginedStream
Creates a new mapped stream.- Parameters:
source
- the stream to wrap.root
- the stream on which to delegateskip
andlimit
operations.
-
-
Method Details
-
skip
Discards the specified number of elements. This method delegates the operation to the root stream. -
limit
Truncates this stream to the given number of elements. This method delegates the operation to the root stream. -
count
public long count()Returns the number of elements in this stream. This method delegates the operation to the root stream. -
mapToDouble
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
mapToDouble
in interfaceStream<T>
- Overrides:
mapToDouble
in classStreamWrapper<T>
- Parameters:
mapper
- function to apply to each element.- Returns:
- the new stream.
-
distinct
Description copied from class:StreamWrapper
Returns a stream with distinct elements of this stream. -
unordered
Description copied from class:StreamWrapper
Returns an equivalent stream that is unordered.- Specified by:
unordered
in interfaceBaseStream<T,
Stream<T>> - Overrides:
unordered
in classStreamWrapper<T>
-
sorted
Description copied from class:StreamWrapper
Returns a stream with elements of this stream sorted in natural order. -
sorted
Description copied from class:StreamWrapper
Returns a stream with elements of this stream sorted using the given comparator. -
filter
Description copied from class:StreamWrapper
Returns a stream with elements of this stream that match the given predicate.
-