Package org.hibernate.query.spi
Class StreamDecorator<R>
- java.lang.Object
-
- org.hibernate.query.spi.StreamDecorator<R>
-
- All Implemented Interfaces:
AutoCloseable
,BaseStream<R,Stream<R>>
,Stream<R>
public class StreamDecorator<R> extends Object implements Stream<R>
TheStreamDecorator
wraps a JavaStream
and registers acloseHandler
which is passed further to any resultingStream
. The goal of theStreamDecorator
is to close the underlyingStream
upon calling a terminal operation.- Since:
- 5.4
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface java.util.stream.Stream
Stream.Builder<T extends Object>
-
-
Constructor Summary
Constructors Constructor Description StreamDecorator(Stream<R> delegate, Runnable closeHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allMatch(Predicate<? super R> predicate)
boolean
anyMatch(Predicate<? super R> predicate)
void
close()
<R1> R1
collect(Supplier<R1> supplier, BiConsumer<R1,? super R> accumulator, BiConsumer<R1,R1> combiner)
<R1,A>
R1collect(Collector<? super R,A,R1> collector)
long
count()
Stream<R>
distinct()
Stream<R>
dropWhile(Predicate<? super R> predicate)
Stream<R>
filter(Predicate<? super R> predicate)
Optional<R>
findAny()
Optional<R>
findFirst()
<R1> Stream<R1>
flatMap(Function<? super R,? extends Stream<? extends R1>> mapper)
DoubleStream
flatMapToDouble(Function<? super R,? extends DoubleStream> mapper)
IntStream
flatMapToInt(Function<? super R,? extends IntStream> mapper)
LongStream
flatMapToLong(Function<? super R,? extends LongStream> mapper)
void
forEach(Consumer<? super R> action)
void
forEachOrdered(Consumer<? super R> action)
boolean
isParallel()
Iterator<R>
iterator()
Stream<R>
limit(long maxSize)
<R1> Stream<R1>
map(Function<? super R,? extends R1> mapper)
DoubleStream
mapToDouble(ToDoubleFunction<? super R> mapper)
IntStream
mapToInt(ToIntFunction<? super R> mapper)
LongStream
mapToLong(ToLongFunction<? super R> mapper)
Optional<R>
max(Comparator<? super R> comparator)
Optional<R>
min(Comparator<? super R> comparator)
boolean
noneMatch(Predicate<? super R> predicate)
Stream<R>
onClose(Runnable closeHandler)
Stream<R>
parallel()
Stream<R>
peek(Consumer<? super R> action)
Optional<R>
reduce(BinaryOperator<R> accumulator)
R
reduce(R identity, BinaryOperator<R> accumulator)
<U> U
reduce(U identity, BiFunction<U,? super R,U> accumulator, BinaryOperator<U> combiner)
Stream<R>
sequential()
Stream<R>
skip(long n)
Stream<R>
sorted()
Stream<R>
sorted(Comparator<? super R> comparator)
Spliterator<R>
spliterator()
Stream<R>
takeWhile(Predicate<? super R> predicate)
Object[]
toArray()
<A> A[]
toArray(IntFunction<A[]> generator)
Stream<R>
unordered()
-
-
-
Method Detail
-
mapToInt
public IntStream mapToInt(ToIntFunction<? super R> mapper)
-
mapToLong
public LongStream mapToLong(ToLongFunction<? super R> mapper)
-
mapToDouble
public DoubleStream mapToDouble(ToDoubleFunction<? super R> mapper)
- Specified by:
mapToDouble
in interfaceStream<R>
-
flatMapToInt
public IntStream flatMapToInt(Function<? super R,? extends IntStream> mapper)
- Specified by:
flatMapToInt
in interfaceStream<R>
-
flatMapToLong
public LongStream flatMapToLong(Function<? super R,? extends LongStream> mapper)
- Specified by:
flatMapToLong
in interfaceStream<R>
-
flatMapToDouble
public DoubleStream flatMapToDouble(Function<? super R,? extends DoubleStream> mapper)
- Specified by:
flatMapToDouble
in interfaceStream<R>
-
sorted
public Stream<R> sorted(Comparator<? super R> comparator)
-
forEachOrdered
public void forEachOrdered(Consumer<? super R> action)
- Specified by:
forEachOrdered
in interfaceStream<R>
-
toArray
public <A> A[] toArray(IntFunction<A[]> generator)
-
reduce
public R reduce(R identity, BinaryOperator<R> accumulator)
-
reduce
public Optional<R> reduce(BinaryOperator<R> accumulator)
-
reduce
public <U> U reduce(U identity, BiFunction<U,? super R,U> accumulator, BinaryOperator<U> combiner)
-
collect
public <R1> R1 collect(Supplier<R1> supplier, BiConsumer<R1,? super R> accumulator, BiConsumer<R1,R1> combiner)
-
min
public Optional<R> min(Comparator<? super R> comparator)
-
max
public Optional<R> max(Comparator<? super R> comparator)
-
spliterator
public Spliterator<R> spliterator()
- Specified by:
spliterator
in interfaceBaseStream<R,Stream<R>>
-
isParallel
public boolean isParallel()
- Specified by:
isParallel
in interfaceBaseStream<R,Stream<R>>
-
sequential
public Stream<R> sequential()
- Specified by:
sequential
in interfaceBaseStream<R,Stream<R>>
-
unordered
public Stream<R> unordered()
- Specified by:
unordered
in interfaceBaseStream<R,Stream<R>>
-
onClose
public Stream<R> onClose(Runnable closeHandler)
- Specified by:
onClose
in interfaceBaseStream<R,Stream<R>>
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceBaseStream<R,Stream<R>>
-
-