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 inStreaminterface.
- 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 delegateskipandlimitoperations.Fields inherited from class org.apache.sis.internal.stream.StreamWrapper
sourceFields 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 TypeMethodDescriptionlongcount()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, toArrayMethods inherited from class org.apache.sis.internal.stream.BaseStreamWrapper
close, inactive, isParallelMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.stream.BaseStream
close, isParallel
-
Field Details
-
root
The root stream on which to delegateskipandlimitoperations.
-
-
Constructor Details
-
PaginedStream
Creates a new mapped stream.- Parameters:
source- the stream to wrap.root- the stream on which to delegateskipandlimitoperations.
-
-
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:
mapToDoublein interfaceStream<T>- Overrides:
mapToDoublein classStreamWrapper<T>- Parameters:
mapper- function to apply to each element.- Returns:
- the new stream.
-
distinct
Description copied from class:StreamWrapperReturns a stream with distinct elements of this stream. -
unordered
Description copied from class:StreamWrapperReturns an equivalent stream that is unordered.- Specified by:
unorderedin interfaceBaseStream<T,Stream<T>> - Overrides:
unorderedin classStreamWrapper<T>
-
sorted
Description copied from class:StreamWrapperReturns a stream with elements of this stream sorted in natural order. -
sorted
Description copied from class:StreamWrapperReturns a stream with elements of this stream sorted using the given comparator. -
filter
Description copied from class:StreamWrapperReturns a stream with elements of this stream that match the given predicate.
-