T
- The type of the Stream being wrappedpublic class DebugStream<T> extends Object implements Stream<T>, DebuggableStreaming<T>
Stream
wrapper, which allows overriding of only
two methods to allow seeing stream operation in realtime.Stream.Builder<T>
Modifier | Constructor and Description |
---|---|
protected |
DebugStream(Stream<T> stream,
boolean outputResults) |
Modifier and Type | Method and Description |
---|---|
boolean |
allMatch(Predicate<? super T> predicate) |
boolean |
anyMatch(Predicate<? super T> predicate) |
void |
close() |
<R,A> R |
collect(Collector<? super T,A,R> collector) |
<R> R |
collect(Supplier<R> supplier,
BiConsumer<R,? super T> accumulator,
BiConsumer<R,R> combiner) |
long |
count() |
Stream<T> |
distinct() |
Stream<T> |
filter(Predicate<? super T> predicate) |
Optional<T> |
findAny() |
Optional<T> |
findFirst() |
<R> Stream<R> |
flatMap(Function<? super T,? extends Stream<? extends R>> mapper) |
DoubleStream |
flatMapToDouble(Function<? super T,? extends DoubleStream> mapper) |
IntStream |
flatMapToInt(Function<? super T,? extends IntStream> mapper) |
LongStream |
flatMapToLong(Function<? super T,? extends LongStream> mapper) |
void |
forEach(Consumer<? super T> action) |
void |
forEachOrdered(Consumer<? super T> action) |
Stream<T> |
getRawStream() |
boolean |
isOutputtingResults() |
boolean |
isParallel() |
Iterator<T> |
iterator() |
Stream<T> |
limit(long maxSize) |
<R> Stream<R> |
map(Function<? super T,? extends R> mapper) |
DoubleStream |
mapToDouble(ToDoubleFunction<? super T> mapper) |
IntStream |
mapToInt(ToIntFunction<? super T> mapper) |
LongStream |
mapToLong(ToLongFunction<? super T> mapper) |
Optional<T> |
max(Comparator<? super T> comparator) |
Optional<T> |
min(Comparator<? super T> comparator) |
boolean |
noneMatch(Predicate<? super T> predicate) |
static <D> DebugStream<D> |
of(Stream<D> stream)
Creates a new
DebugStream using the default type |
static <D> DebugStream<D> |
of(Stream<D> stream,
boolean outputResults)
Creates a new
DebugStream using the default type |
static <D> DebugStream<D> |
of(Stream<D> stream,
boolean outputResults,
Class<? extends DebugStream> type)
Instantiates a new
DebugStream of the type parameter passed to the method. |
static <D> DebugStream<D> |
of(Stream<D> stream,
Class<? extends DebugStream<D>> type)
Instantiates a new
DebugStream of the type parameter passed to the method. |
Stream<T> |
onClose(Runnable closeHandler) |
protected <R> R |
operate(Function<? super Stream<T>,? extends R> action)
Overridable method which runs the appropriate
Stream action, and outputs the result as well as
which numerical call it is. |
protected void |
operateVoid(Consumer<? super Stream<T>> action)
Overridable method which runs the appropriate
Stream action, and outputs the result as well as
which numerical call it is. |
Stream<T> |
parallel() |
Stream<T> |
peek(Consumer<? super T> action) |
Optional<T> |
reduce(BinaryOperator<T> accumulator) |
T |
reduce(T identity,
BinaryOperator<T> accumulator) |
<U> U |
reduce(U identity,
BiFunction<U,? super T,U> accumulator,
BinaryOperator<U> combiner) |
Stream<T> |
sequential() |
Stream<T> |
skip(long n) |
Stream<T> |
sorted() |
Stream<T> |
sorted(Comparator<? super T> comparator) |
Spliterator<T> |
spliterator() |
Object[] |
toArray() |
<A> A[] |
toArray(IntFunction<A[]> generator) |
Stream<T> |
unordered() |
public static <D> DebugStream<D> of(Stream<D> stream)
DebugStream
using the default typepublic static <D> DebugStream<D> of(Stream<D> stream, boolean outputResults)
DebugStream
using the default typeD
- The type of the Stream
elementsstream
- The Stream
to wrapoutputResults
- true
to output the results of the Stream
as it is operated uponDebugStream
wrapper of the provided Stream
public static <D> DebugStream<D> of(Stream<D> stream, Class<? extends DebugStream<D>> type)
DebugStream
of the type parameter passed to the method. This is the appropriate
way to instantiate the DebugStream
, as future caching mechanisms will be in place to optimize this.
You may however expose the constructor if you so choose.D
- The type of the Stream
elementsstream
- The Stream
to create a DebugStream
of.type
- The class representing the type of the DebugStream
to instantiateDebugStream
of the provided Stream
public static <D> DebugStream<D> of(Stream<D> stream, boolean outputResults, Class<? extends DebugStream> type)
DebugStream
of the type parameter passed to the method. This is the appropriate
way to instantiate the DebugStream
, as future caching mechanisms will be in place to optimize this.
You may however expose the constructor if you so choose.D
- The type of the Stream
elementsstream
- The Stream
to create a DebugStream
of.outputResults
- true
to output the results of the Stream<T>
as it is operated upontype
- The class representing the type of the DebugStream
to instantiateDebugStream
of the provided Stream
, or the base class instance of
DebugStream
if the type either failed to instantiate or was null
.protected <R> R operate(Function<? super Stream<T>,? extends R> action)
Stream
action, and outputs the result as well as
which numerical call it is. For example, the third #filter calll will be printed as
DebugStream#filter[2]: <result>
. The output of result
will be substringed to a maximum
of 50 characters, to keep the console from being spammed with large datasets. Additionally, method names with
differing method parameters will be grouped under the same aliases and therefore, the same method "counter".
Stream
will need to be recreated each time.protected void operateVoid(Consumer<? super Stream<T>> action)
Stream
action, and outputs the result as well as
which numerical call it is. Due to this being a void operation on a Consumer
, the result output will
always be null
.action
- The Consumer
representing the action taken on the Stream
operate(Function)
public IntStream mapToInt(ToIntFunction<? super T> mapper)
public LongStream mapToLong(ToLongFunction<? super T> mapper)
public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper)
mapToDouble
in interface Stream<T>
public IntStream flatMapToInt(Function<? super T,? extends IntStream> mapper)
flatMapToInt
in interface Stream<T>
public LongStream flatMapToLong(Function<? super T,? extends LongStream> mapper)
flatMapToLong
in interface Stream<T>
public DoubleStream flatMapToDouble(Function<? super T,? extends DoubleStream> mapper)
flatMapToDouble
in interface Stream<T>
public Stream<T> sorted(Comparator<? super T> comparator)
public void forEachOrdered(Consumer<? super T> action)
forEachOrdered
in interface Stream<T>
public <A> A[] toArray(IntFunction<A[]> generator)
public T reduce(T identity, BinaryOperator<T> accumulator)
public Optional<T> reduce(BinaryOperator<T> accumulator)
public <U> U reduce(U identity, BiFunction<U,? super T,U> accumulator, BinaryOperator<U> combiner)
public <R> R collect(Supplier<R> supplier, BiConsumer<R,? super T> accumulator, BiConsumer<R,R> combiner)
public Optional<T> min(Comparator<? super T> comparator)
public Optional<T> max(Comparator<? super T> comparator)
public Spliterator<T> spliterator()
spliterator
in interface BaseStream<T,Stream<T>>
public boolean isParallel()
isParallel
in interface BaseStream<T,Stream<T>>
public Stream<T> sequential()
sequential
in interface BaseStream<T,Stream<T>>
public Stream<T> onClose(Runnable closeHandler)
onClose
in interface BaseStream<T,Stream<T>>
public void close()
close
in interface AutoCloseable
close
in interface BaseStream<T,Stream<T>>
public Stream<T> getRawStream()
getRawStream
in interface DebuggableStreaming<T>
public boolean isOutputtingResults()
isOutputtingResults
in interface DebuggableStreaming<T>
Copyright © 2017. All rights reserved.