Top Description Fields Constructors Methods
org.hibernate.query.spi

public Class StreamDecorator<R>

extends Object
implements Stream<R>
Class Inheritance
All Implemented Interfaces
java.util.stream.Stream, java.util.stream.BaseStream, java.lang.AutoCloseable
Annotations
@Incubating
Imports
java.lang.reflect.InvocationTargetException, java.util.Comparator, .Iterator, .Optional, .Spliterator, java.util.function.BiConsumer, .BiFunction, .BinaryOperator, .Consumer, .Function, .IntFunction, .Predicate, .Supplier, .ToDoubleFunction, .ToIntFunction, .ToLongFunction, java.util.stream.Collector, .DoubleStream, .IntStream, .LongStream, .Stream, org.hibernate.HibernateException, .Incubating, org.hibernate.internal.util.ReflectHelper

The StreamDecorator wraps a Java Stream and registers a closeHandler which is passed further to any resulting Stream. The goal of the StreamDecorator is to close the underlying Stream upon calling a terminal operation.
Author
Vlad Mihalcea
Since
5.4

Field Summary

Modifier and TypeField and Description
private final Runnable
private final Stream<R>

Constructor Summary

AccessConstructor and Description
public
StreamDecorator(Stream<R> delegate, Runnable closeHandler)

Method Summary

Modifier and TypeMethod and Description
public boolean
allMatch(Predicate<? super R>
a non-interfering, stateless predicate to apply to elements of this stream
predicate
)

Implements java.util.stream.Stream.allMatch.

Returns whether all elements of this stream match the provided predicate.
public boolean
anyMatch(Predicate<? super R>
a non-interfering, stateless predicate to apply to elements of this stream
predicate
)

Implements java.util.stream.Stream.anyMatch.

Returns whether any elements of this stream match the provided predicate.
public void
close()

Implements java.util.stream.BaseStream.close.

Closes this stream, causing all close handlers for this stream pipeline to be called.
public <R1> R1
collect(Supplier<R1>
a function that creates a new mutable result container. For a parallel execution, this function may be called multiple times and must return a fresh value each time.
supplier
,
BiConsumer<R1, ? super R>
an associative, non-interfering, stateless function that must fold an element into a result container.
accumulator
,
BiConsumer<R1, R1>
an associative, non-interfering, stateless function that accepts two partial result containers and merges them, which must be compatible with the accumulator function. The combiner function must fold the elements from the second result container into the first result container.
combiner
)

Implements java.util.stream.Stream.collect.

Performs a mutable reduction operation on the elements of this stream.
public <R1, A> R1
collect(Collector<? super R, A, R1>
the Collector describing the reduction
collector
)

Implements java.util.stream.Stream.collect.

Performs a mutable reduction operation on the elements of this stream using a Collector.
public long
count()

Implements java.util.stream.Stream.count.

Returns the count of elements in this stream.
public Stream<R>
distinct()

Implements java.util.stream.Stream.distinct.

Returns a stream consisting of the distinct elements (according to Object#equals(Object)) of this stream.
public Stream<R>
dropWhile(Predicate<? super R>
a non-interfering, stateless predicate to apply to elements to determine the longest prefix of elements.
predicate
)

Overrides default java.util.stream.Stream.dropWhile.

Returns, if this stream is ordered, a stream consisting of the remaining elements of this stream after dropping the longest prefix of elements that match the given predicate.
public Stream<R>
filter(Predicate<? super R>
a non-interfering, stateless predicate to apply to each element to determine if it should be included
predicate
)

Implements java.util.stream.Stream.filter.

Returns a stream consisting of the elements of this stream that match the given predicate.
public Optional<R>
findAny()

Implements java.util.stream.Stream.findAny.

Returns an Optional describing some element of the stream, or an empty Optional if the stream is empty.
public Optional<R>
findFirst()

Implements java.util.stream.Stream.findFirst.

Returns an Optional describing the first element of this stream, or an empty Optional if the stream is empty.
public <R1> Stream<R1>
flatMap(Function<? super R, ? extends Stream<? extends R1>>
a non-interfering, stateless function to apply to each element which produces a stream of new values
mapper
)

Implements java.util.stream.Stream.flatMap.

Returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
public DoubleStream
flatMapToDouble(Function<? super R, ? extends DoubleStream>
a non-interfering, stateless function to apply to each element which produces a stream of new values
mapper
)

Implements java.util.stream.Stream.flatMapToDouble.

Returns an DoubleStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
public IntStream
flatMapToInt(Function<? super R, ? extends IntStream>
a non-interfering, stateless function to apply to each element which produces a stream of new values
mapper
)

Implements java.util.stream.Stream.flatMapToInt.

Returns an IntStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
public LongStream
flatMapToLong(Function<? super R, ? extends LongStream>
a non-interfering, stateless function to apply to each element which produces a stream of new values
mapper
)

Implements java.util.stream.Stream.flatMapToLong.

Returns an LongStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
public void
forEach(Consumer<? super R>
a non-interfering action to perform on the elements
action
)

Implements java.util.stream.Stream.forEach.

Performs an action for each element of this stream.
public void
forEachOrdered(Consumer<? super R>
a non-interfering action to perform on the elements
action
)

Implements java.util.stream.Stream.forEachOrdered.

Performs an action for each element of this stream, in the encounter order of the stream if the stream has a defined encounter order.
public boolean
isParallel()

Implements java.util.stream.BaseStream.isParallel.

Returns whether this stream, if a terminal operation were to be executed, would execute in parallel.
public Iterator<R>
iterator()

Implements java.util.stream.BaseStream.iterator.

Returns an iterator for the elements of this stream.
public Stream<R>
limit(long
the number of elements the stream should be limited to
maxSize
)

Implements java.util.stream.Stream.limit.

Returns a stream consisting of the elements of this stream, truncated to be no longer than maxSize in length.
public <R1> Stream<R1>
map(Function<? super R, ? extends R1>
a non-interfering, stateless function to apply to each element
mapper
)

Implements java.util.stream.Stream.map.

Returns a stream consisting of the results of applying the given function to the elements of this stream.
public DoubleStream
mapToDouble(ToDoubleFunction<? super R>
a non-interfering, stateless function to apply to each element
mapper
)

Implements java.util.stream.Stream.mapToDouble.

Returns a DoubleStream consisting of the results of applying the given function to the elements of this stream.
public IntStream
mapToInt(ToIntFunction<? super R>
a non-interfering, stateless function to apply to each element
mapper
)

Implements java.util.stream.Stream.mapToInt.

Returns an IntStream consisting of the results of applying the given function to the elements of this stream.
public LongStream
mapToLong(ToLongFunction<? super R>
a non-interfering, stateless function to apply to each element
mapper
)

Implements java.util.stream.Stream.mapToLong.

Returns a LongStream consisting of the results of applying the given function to the elements of this stream.
public Optional<R>
max(Comparator<? super R>
a non-interfering, stateless Comparator to compare elements of this stream
comparator
)

Implements java.util.stream.Stream.max.

Returns the maximum element of this stream according to the provided Comparator.
public Optional<R>
min(Comparator<? super R>
a non-interfering, stateless Comparator to compare elements of this stream
comparator
)

Implements java.util.stream.Stream.min.

Returns the minimum element of this stream according to the provided Comparator.
public boolean
noneMatch(Predicate<? super R>
a non-interfering, stateless predicate to apply to elements of this stream
predicate
)

Implements java.util.stream.Stream.noneMatch.

Returns whether no elements of this stream match the provided predicate.
public Stream<R>
onClose(Runnable
A task to execute when the stream is closed
closeHandler
)

Implements java.util.stream.BaseStream.onClose.

Returns an equivalent stream with an additional close handler.
public Stream<R>
parallel()

Implements java.util.stream.BaseStream.parallel.

Returns an equivalent stream that is parallel.
public Stream<R>
peek(Consumer<? super R>
a non-interfering action to perform on the elements as they are consumed from the stream
action
)

Implements java.util.stream.Stream.peek.

Returns a stream consisting of the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.
public R
reduce(R
the identity value for the accumulating function
identity
,
BinaryOperator<R>
an associative, non-interfering, stateless function for combining two values
accumulator
)

Implements java.util.stream.Stream.reduce.

Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value.
public Optional<R>
reduce(BinaryOperator<R>
an associative, non-interfering, stateless function for combining two values
accumulator
)

Implements java.util.stream.Stream.reduce.

Performs a reduction on the elements of this stream, using an associative accumulation function, and returns an Optional describing the reduced value, if any.
public <U> U
reduce(U
the identity value for the combiner function
identity
,
BiFunction<U, ? super R, U>
an associative, non-interfering, stateless function for incorporating an additional element into a result
accumulator
,
BinaryOperator<U>
an associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function
combiner
)

Implements java.util.stream.Stream.reduce.

Performs a reduction on the elements of this stream, using the provided identity, accumulation and combining functions.
public Stream<R>
sequential()

Implements java.util.stream.BaseStream.sequential.

Returns an equivalent stream that is sequential.
public Stream<R>
skip(long
the number of leading elements to skip
n
)

Implements java.util.stream.Stream.skip.

Returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream.
public Stream<R>
sorted()

Implements java.util.stream.Stream.sorted.

Returns a stream consisting of the elements of this stream, sorted according to natural order.
public Stream<R>
sorted(Comparator<? super R>
a non-interfering, stateless Comparator to be used to compare stream elements
comparator
)

Implements java.util.stream.Stream.sorted.

Returns a stream consisting of the elements of this stream, sorted according to the provided Comparator.
public Spliterator<R>
spliterator()

Implements java.util.stream.BaseStream.spliterator.

Returns a spliterator for the elements of this stream.
public Stream<R>
takeWhile(Predicate<? super R>
a non-interfering, stateless predicate to apply to elements to determine the longest prefix of elements.
predicate
)

Overrides default java.util.stream.Stream.takeWhile.

Returns, if this stream is ordered, a stream consisting of the longest prefix of elements taken from this stream that match the given predicate.
public Object[]
toArray()

Implements java.util.stream.Stream.toArray.

Returns an array containing the elements of this stream.
public <A> A[]
toArray(IntFunction<A[]>
a function which produces a new array of the desired type and the provided length
generator
)

Implements java.util.stream.Stream.toArray.

Returns an array containing the elements of this stream, using the provided generator function to allocate the returned array, as well as any additional arrays that might be required for a partitioned execution or for resizing.
public Stream<R>
unordered()

Implements java.util.stream.BaseStream.unordered.

Returns an equivalent stream that is unordered.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait