Class ExStream<T>
- Type Parameters:
T- the type of the stream elements
- All Implemented Interfaces:
AutoCloseable, BaseStream<T, Stream<T>>, Stream<T>
Implements versions of all methods from Stream that use functional interfaces, using their counterparts with Exceptions instead, e.g.
exMap(ExFunction) in parallel to map(Function).
If these functional interfaces throw a checked exception, a ExException will be thrown instead.
This will have the original exception as its cause.
Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream (except if it is itself such an operation).
-
Nested Class Summary
Nested classes/interfaces inherited from interface Stream
Stream.Builder<T> -
Method Summary
Modifier and TypeMethodDescriptiondistinct()static <T> ExStream<T> empty()Returns an empty instance.<R> RexCollect(ExSupplier<R, ?> supplier, ExBiConsumer<R, ? super T, ?> accumulator, ExBiConsumer<R, R, ?> combiner) Equivalent ofStream.collect(Supplier, BiConsumer, BiConsumer).exDropWhile(ExPredicate<? super T, ?> predicate) Equivalent ofStream.dropWhile(Predicate).exFilter(ExPredicate<? super T, ?> predicate) Equivalent ofStream.filter(Predicate).<R> ExStream<R> exFlatMap(ExFunction<? super T, ? extends Stream<? extends R>, ?> mapper) Equivalent ofStream.flatMap(Function).exFlatMapToDouble(ExFunction<? super T, ? extends DoubleStream, ?> mapper) Equivalent ofStream.flatMapToDouble(Function).exFlatMapToInt(ExFunction<? super T, ? extends IntStream, ?> mapper) Equivalent ofStream.flatMapToInt(Function).exFlatMapToLong(ExFunction<? super T, ? extends LongStream, ?> mapper) Equivalent ofStream.flatMapToLong(Function).voidexForEach(ExConsumer<? super T, ?> action) Equivalent ofStream.forEach(Consumer).voidexForEachOrdered(ExConsumer<? super T, ?> action) Equivalent ofStream.forEachOrdered(Consumer).<R> ExStream<R> exMap(ExFunction<? super T, ? extends R, ?> mapper) Equivalent ofStream.map(Function).<R> ExStream<R> exMapMulti(ExBiConsumer<? super T, ? super Consumer<R>, ?> mapper) Equivalent ofStream.mapMulti(BiConsumer).exMapMultiToDouble(ExBiConsumer<? super T, ? super DoubleConsumer, ?> mapper) Equivalent ofStream.mapMultiToDouble(BiConsumer).exMapMultiToInt(ExBiConsumer<? super T, ? super IntConsumer, ?> mapper) Equivalent ofStream.mapMultiToInt(BiConsumer).exMapMultiToLong(ExBiConsumer<? super T, ? super LongConsumer, ?> mapper) Equivalent ofStream.mapMultiToLong(BiConsumer).exMapToDouble(ExToDoubleFunction<? super T, ?> mapper) Equivalent ofStream.mapToDouble(ToDoubleFunction).exMapToInt(ExToIntFunction<? super T, ?> mapper) Equivalent ofStream.mapToInt(ToIntFunction).exMapToLong(ExToLongFunction<? super T, ?> mapper) Equivalent ofStream.mapToLong(ToLongFunction).exPeek(ExConsumer<? super T, ?> action) Equivalent ofStream.peek(Consumer).exReduce(ExBinaryOperator<T, ?> accumulator) Equivalent ofStream.reduce(BinaryOperator).exReduce(T identity, ExBinaryOperator<T, ?> accumulator) Equivalent ofStream.reduce(Object, BinaryOperator).<U> UexReduce(U identity, ExBiFunction<U, ? super T, U, ?> accumulator, ExBinaryOperator<U, ?> combiner) Equivalent ofStream.reduce(Object, BiFunction, BinaryOperator).exTakeWhile(ExPredicate<? super T, ?> predicate) Equivalent ofStream.takeWhile(Predicate).<R> ExStream<R> flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) flatMapToInt(Function<? super T, ? extends IntStream> mapper) flatMapToLong(Function<? super T, ? extends LongStream> mapper) limit(long maxSize) <R> ExStream<R> <R> ExStream<R> mapMulti(BiConsumer<? super T, ? super Consumer<R>> mapper) mapMultiToDouble(BiConsumer<? super T, ? super DoubleConsumer> mapper) mapMultiToInt(BiConsumer<? super T, ? super IntConsumer> mapper) mapMultiToLong(BiConsumer<? super T, ? super LongConsumer> mapper) mapToDouble(ToDoubleFunction<? super T> mapper) mapToInt(ToIntFunction<? super T> mapper) mapToLong(ToLongFunction<? super T> mapper) static <T> ExStream<T> of(Collection<T> collection) Create an instance from a collection.of(DoubleStream stream) Create an instance from an existing DoubleStream.Create an instance from an existing IntStream.of(LongStream stream) Create an instance from an existing IntStream.static <T> ExStream<T> Create an instance from an existing Stream.static <T> ExStream<T> of(T t) Returns an instance containing a single element.static <T> ExStream<T> of(T... values) Returns an instance whose elements are the specified values.static <T> ExStream<T> ofNullable(@Nullable T t) Returns an instance containing a single element, if non-null, otherwise returns an empty instance.skip(long n) sorted()sorted(Comparator<? super T> comparator) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseStream
close, isParallel, iterator, onClose, parallel, sequential, spliterator, unordered
-
Method Details
-
of
-
of
Create an instance from an existing DoubleStream.- Parameters:
stream- existing stream- Returns:
- instance from an existing Stream
-
of
-
of
Create an instance from an existing IntStream.- Parameters:
stream- existing stream- Returns:
- instance from an existing Stream
-
of
Create an instance from a collection.- Type Parameters:
T- the type of the stream elements- Parameters:
collection- collection- Returns:
- instance from a collection
-
empty
Returns an empty instance.- Type Parameters:
T- the type of the stream elements- Returns:
- an empty instance
-
of
Returns an instance containing a single element.- Type Parameters:
T- the type of the stream elements- Parameters:
t- the single element- Returns:
- an instance containing a single element
-
ofNullable
Returns an instance containing a single element, if non-null, otherwise returns an empty instance.- Type Parameters:
T- the type of stream elements- Parameters:
t- the single element- Returns:
- a stream with a single element if the specified element is non-null, otherwise an empty stream
-
of
Returns an instance whose elements are the specified values.- Type Parameters:
T- the type of the stream elements- Parameters:
values- the elements of the new stream- Returns:
- the new instance
-
filter
-
map
-
flatMap
-
mapMulti
-
distinct
-
sorted
-
sorted
-
peek
-
limit
-
skip
-
takeWhile
-
dropWhile
-
mapToDouble
- Specified by:
mapToDoublein interfaceStream<T>
-
flatMapToDouble
- Specified by:
flatMapToDoublein interfaceStream<T>
-
mapMultiToDouble
- Specified by:
mapMultiToDoublein interfaceStream<T>
-
mapToInt
-
flatMapToInt
- Specified by:
flatMapToIntin interfaceStream<T>
-
mapMultiToInt
- Specified by:
mapMultiToIntin interfaceStream<T>
-
mapToLong
-
flatMapToLong
- Specified by:
flatMapToLongin interfaceStream<T>
-
mapMultiToLong
- Specified by:
mapMultiToLongin interfaceStream<T>
-
exFilter
Equivalent ofStream.filter(Predicate).If
predicatethrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
predicate- seeStream.filter(Predicate)- Returns:
- see
Stream.filter(Predicate)
-
exMap
Equivalent ofStream.map(Function).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Type Parameters:
R- The element type of the new stream- Parameters:
mapper- seeStream.map(Function)- Returns:
- see
Stream.map(Function)
-
exMapToDouble
Equivalent ofStream.mapToDouble(ToDoubleFunction).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
mapper- seeStream.mapToDouble(ToDoubleFunction)- Returns:
- see
Stream.mapToDouble(ToDoubleFunction)
-
exMapToInt
Equivalent ofStream.mapToInt(ToIntFunction).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
mapper- seeStream.mapToInt(ToIntFunction)- Returns:
- see
Stream.mapToInt(ToIntFunction)
-
exMapToLong
Equivalent ofStream.mapToLong(ToLongFunction).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
mapper- seeStream.mapToLong(ToLongFunction)- Returns:
- see
Stream.mapToLong(ToLongFunction)
-
exFlatMap
Equivalent ofStream.flatMap(Function).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Type Parameters:
R- The element type of the new stream- Parameters:
mapper- seeStream.flatMap(Function)- Returns:
- see
Stream.flatMap(Function)
-
exFlatMapToDouble
Equivalent ofStream.flatMapToDouble(Function).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
mapper- seeStream.flatMapToDouble(Function)- Returns:
- see
Stream.flatMapToDouble(Function)
-
exFlatMapToInt
Equivalent ofStream.flatMapToInt(Function).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
mapper- seeStream.flatMapToInt(Function)- Returns:
- see
Stream.flatMapToInt(Function)
-
exFlatMapToLong
Equivalent ofStream.flatMapToLong(Function).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
mapper- seeStream.flatMapToLong(Function)- Returns:
- see
Stream.flatMapToLong(Function)
-
exMapMulti
Equivalent ofStream.mapMulti(BiConsumer).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Type Parameters:
R- The element type of the new stream- Parameters:
mapper- seeStream.mapMulti(BiConsumer)- Returns:
- see
Stream.mapMulti(BiConsumer)
-
exMapMultiToDouble
Equivalent ofStream.mapMultiToDouble(BiConsumer).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
mapper- seeStream.mapMultiToDouble(BiConsumer)- Returns:
- see
Stream.mapMultiToDouble(BiConsumer)
-
exMapMultiToInt
Equivalent ofStream.mapMultiToInt(BiConsumer).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
mapper- seeStream.mapMultiToInt(BiConsumer)- Returns:
- see
Stream.mapMultiToInt(BiConsumer)
-
exMapMultiToLong
Equivalent ofStream.mapMultiToLong(BiConsumer).If
mapperthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when a method is called, but only when a terminal operation or a stateful intermediate operation is used on the stream.
- Parameters:
mapper- seeStream.mapMultiToLong(BiConsumer)- Returns:
- see
Stream.mapMultiToLong(BiConsumer)
-
exPeek
Equivalent ofStream.peek(Consumer).If
actionthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Parameters:
action- seeStream.peek(Consumer)- Returns:
- see
Stream.peek(Consumer)
-
exTakeWhile
Equivalent ofStream.takeWhile(Predicate).If
predicatethrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Parameters:
predicate- seeStream.takeWhile(Predicate)- Returns:
- see
Stream.takeWhile(Predicate)
-
exDropWhile
Equivalent ofStream.dropWhile(Predicate).If
predicatethrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.Note that this exception will likely not be thrown when this method is called, but only when a terminal operation like
Stream.toList()is used on the stream.- Parameters:
predicate- seeStream.dropWhile(Predicate)- Returns:
- see
Stream.dropWhile(Predicate)
-
exForEach
Equivalent ofStream.forEach(Consumer).If
actionthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Parameters:
action- seeStream.forEach(Consumer)
-
exForEachOrdered
Equivalent ofStream.forEachOrdered(Consumer).If
actionthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Parameters:
action- seeStream.forEachOrdered(Consumer)
-
exReduce
Equivalent ofStream.reduce(BinaryOperator).If
accumulatorthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Parameters:
accumulator- seeStream.reduce(BinaryOperator)- Returns:
- see
Stream.reduce(BinaryOperator)
-
exReduce
Equivalent ofStream.reduce(Object, BinaryOperator).If
accumulatorthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Parameters:
identity- seeStream.reduce(Object, BiFunction, BinaryOperator)accumulator- seeStream.reduce(Object, BinaryOperator)- Returns:
- see
Stream.reduce(Object, BinaryOperator)
-
exReduce
public <U> U exReduce(U identity, ExBiFunction<U, ? super T, U, ?> accumulator, ExBinaryOperator<U, ?> combiner) Equivalent ofStream.reduce(Object, BiFunction, BinaryOperator).If
accumulatororcombinerthrow a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Type Parameters:
U- the element type of the new stream- Parameters:
identity- seeStream.reduce(Object, BiFunction, BinaryOperator)accumulator- seeStream.reduce(Object, BiFunction, BinaryOperator)combiner- seeStream.reduce(Object, BiFunction, BinaryOperator)- Returns:
- see
Stream.reduce(Object, BiFunction, BinaryOperator)
-
exCollect
public <R> R exCollect(ExSupplier<R, ?> supplier, ExBiConsumer<R, ? super T, ?> accumulator, ExBiConsumer<R, R, ?> combiner) Equivalent ofStream.collect(Supplier, BiConsumer, BiConsumer).If
supplier,accumulatororcombinerthrow a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Type Parameters:
R- the type of the mutable result container- Parameters:
supplier- seeStream.collect(Supplier, BiConsumer, BiConsumer)accumulator- seeStream.collect(Supplier, BiConsumer, BiConsumer)combiner- seeStream.collect(Supplier, BiConsumer, BiConsumer)- Returns:
- see
Stream.collect(Supplier, BiConsumer, BiConsumer)
-