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.
map(Class, 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 TypeMethodDescription<R, E extends Exception>
Rcollect(Class<E> exceptionClass, ExSupplier<R, ? extends E> supplier, ExBiConsumer<R, ? super T, ? extends E> accumulator, ExBiConsumer<R, R, ? extends E> combiner) Equivalent ofStream.collect(Supplier, BiConsumer, BiConsumer).distinct()dropWhile(Class<E> exceptionClass, ExPredicate<? super T, ? extends E> predicate) Equivalent ofStream.dropWhile(Predicate).static <T> ExStream<T> empty()Returns an empty instance.filter(Class<E> exceptionClass, ExPredicate<? super T, ? extends E> predicate) Equivalent ofStream.filter(Predicate).flatMap(Class<E> exceptionClass, ExFunction<? super T, ? extends Stream<? extends R>, ? extends E> mapper) Equivalent ofStream.flatMap(Function).<R> ExStream<R> <E extends Exception>
ExDoubleStreamflatMapToDouble(Class<E> exceptionClass, ExFunction<? super T, ? extends DoubleStream, ? extends E> mapper) Equivalent ofStream.flatMapToDouble(Function).flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) <E extends Exception>
ExIntStreamflatMapToInt(Class<E> exceptionClass, ExFunction<? super T, ? extends IntStream, ? extends E> mapper) Equivalent ofStream.flatMapToInt(Function).flatMapToInt(Function<? super T, ? extends IntStream> mapper) <E extends Exception>
ExLongStreamflatMapToLong(Class<E> exceptionClass, ExFunction<? super T, ? extends LongStream, ? extends E> mapper) Equivalent ofStream.flatMapToLong(Function).flatMapToLong(Function<? super T, ? extends LongStream> mapper) <E extends Exception>
voidforEach(Class<E> exceptionClass, ExConsumer<? super T, ? extends E> action) Equivalent ofStream.forEach(Consumer).<E extends Exception>
voidforEachOrdered(Class<E> exceptionClass, ExConsumer<? super T, ? extends E> action) Equivalent ofStream.forEachOrdered(Consumer).limit(long maxSize) map(Class<E> exceptionClass, ExFunction<? super T, ? extends R, ? extends E> mapper) Equivalent ofStream.map(Function).<R> ExStream<R> mapMulti(Class<E> exceptionClass, ExBiConsumer<? super T, ? super Consumer<R>, ? extends E> mapper) Equivalent ofStream.mapMulti(BiConsumer).<R> ExStream<R> mapMulti(BiConsumer<? super T, ? super Consumer<R>> mapper) <E extends Exception>
ExDoubleStreammapMultiToDouble(Class<E> exceptionClass, ExBiConsumer<? super T, ? super DoubleConsumer, ? extends E> mapper) Equivalent ofStream.mapMultiToDouble(BiConsumer).mapMultiToDouble(BiConsumer<? super T, ? super DoubleConsumer> mapper) <E extends Exception>
ExIntStreammapMultiToInt(Class<E> exceptionClass, ExBiConsumer<? super T, ? super IntConsumer, ? extends E> mapper) Equivalent ofStream.mapMultiToInt(BiConsumer).mapMultiToInt(BiConsumer<? super T, ? super IntConsumer> mapper) <E extends Exception>
ExLongStreammapMultiToLong(Class<E> exceptionClass, ExBiConsumer<? super T, ? super LongConsumer, ? extends E> mapper) Equivalent ofStream.mapMultiToLong(BiConsumer).mapMultiToLong(BiConsumer<? super T, ? super LongConsumer> mapper) <E extends Exception>
ExDoubleStreammapToDouble(Class<E> exceptionClass, ExToDoubleFunction<? super T, ? extends E> mapper) Equivalent ofStream.mapToDouble(ToDoubleFunction).mapToDouble(ToDoubleFunction<? super T> mapper) <E extends Exception>
ExIntStreammapToInt(Class<E> exceptionClass, ExToIntFunction<? super T, ? extends E> mapper) Equivalent ofStream.mapToInt(ToIntFunction).mapToInt(ToIntFunction<? super T> mapper) <E extends Exception>
ExLongStreammapToLong(Class<E> exceptionClass, ExToLongFunction<? super T, ? extends E> mapper) Equivalent ofStream.mapToLong(ToLongFunction).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.peek(Class<E> exceptionClass, ExConsumer<? super T, ? extends E> action) Equivalent ofStream.peek(Consumer).reduce(Class<E> exceptionClass, ExBinaryOperator<T, ? extends E> accumulator) Equivalent ofStream.reduce(BinaryOperator).reduce(Class<E> exceptionClass, T identity, ExBinaryOperator<T, ? extends E> accumulator) Equivalent ofStream.reduce(Object, BinaryOperator).<U, E extends Exception>
Ureduce(Class<E> exceptionClass, U identity, ExBiFunction<U, ? super T, U, ? extends E> accumulator, ExBinaryOperator<U, ? extends E> combiner) Equivalent ofStream.reduce(Object, BiFunction, BinaryOperator).skip(long n) sorted()sorted(Comparator<? super T> comparator) takeWhile(Class<E> exceptionClass, ExPredicate<? super T, ? extends E> predicate) Equivalent ofStream.takeWhile(Predicate).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>
-
filter
public <E extends Exception> ExStream<T> filter(Class<E> exceptionClass, ExPredicate<? super T, ? extends E> predicate) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEpredicate- seeStream.filter(Predicate)- Returns:
- see
Stream.filter(Predicate)
-
map
public <R, E extends Exception> ExStream<R> map(Class<E> exceptionClass, ExFunction<? super T, ? extends R, ? extends E> mapper) 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 streamE- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.map(Function)- Returns:
- see
Stream.map(Function)
-
mapToDouble
public <E extends Exception> ExDoubleStream mapToDouble(Class<E> exceptionClass, ExToDoubleFunction<? super T, ? extends E> mapper) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.mapToDouble(ToDoubleFunction)- Returns:
- see
Stream.mapToDouble(ToDoubleFunction)
-
mapToInt
public <E extends Exception> ExIntStream mapToInt(Class<E> exceptionClass, ExToIntFunction<? super T, ? extends E> mapper) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.mapToInt(ToIntFunction)- Returns:
- see
Stream.mapToInt(ToIntFunction)
-
mapToLong
public <E extends Exception> ExLongStream mapToLong(Class<E> exceptionClass, ExToLongFunction<? super T, ? extends E> mapper) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.mapToLong(ToLongFunction)- Returns:
- see
Stream.mapToLong(ToLongFunction)
-
flatMap
public <R, E extends Exception> ExStream<R> flatMap(Class<E> exceptionClass, ExFunction<? super T, ? extends Stream<? extends R>, ? extends E> mapper) 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 streamE- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.flatMap(Function)- Returns:
- see
Stream.flatMap(Function)
-
flatMapToDouble
public <E extends Exception> ExDoubleStream flatMapToDouble(Class<E> exceptionClass, ExFunction<? super T, ? extends DoubleStream, ? extends E> mapper) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.flatMapToDouble(Function)- Returns:
- see
Stream.flatMapToDouble(Function)
-
flatMapToInt
public <E extends Exception> ExIntStream flatMapToInt(Class<E> exceptionClass, ExFunction<? super T, ? extends IntStream, ? extends E> mapper) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.flatMapToInt(Function)- Returns:
- see
Stream.flatMapToInt(Function)
-
flatMapToLong
public <E extends Exception> ExLongStream flatMapToLong(Class<E> exceptionClass, ExFunction<? super T, ? extends LongStream, ? extends E> mapper) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.flatMapToLong(Function)- Returns:
- see
Stream.flatMapToLong(Function)
-
mapMulti
public <R, E extends Exception> ExStream<R> mapMulti(Class<E> exceptionClass, ExBiConsumer<? super T, ? super Consumer<R>, ? extends E> mapper) 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 streamE- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.mapMulti(BiConsumer)- Returns:
- see
Stream.mapMulti(BiConsumer)
-
mapMultiToDouble
public <E extends Exception> ExDoubleStream mapMultiToDouble(Class<E> exceptionClass, ExBiConsumer<? super T, ? super DoubleConsumer, ? extends E> mapper) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.mapMultiToDouble(BiConsumer)- Returns:
- see
Stream.mapMultiToDouble(BiConsumer)
-
mapMultiToInt
public <E extends Exception> ExIntStream mapMultiToInt(Class<E> exceptionClass, ExBiConsumer<? super T, ? super IntConsumer, ? extends E> mapper) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.mapMultiToInt(BiConsumer)- Returns:
- see
Stream.mapMultiToInt(BiConsumer)
-
mapMultiToLong
public <E extends Exception> ExLongStream mapMultiToLong(Class<E> exceptionClass, ExBiConsumer<? super T, ? super LongConsumer, ? extends E> mapper) 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.
- Type Parameters:
E- The exception type thrown bymapper- Parameters:
exceptionClass- The exception class forEmapper- seeStream.mapMultiToLong(BiConsumer)- Returns:
- see
Stream.mapMultiToLong(BiConsumer)
-
peek
public <E extends Exception> ExStream<T> peek(Class<E> exceptionClass, ExConsumer<? super T, ? extends E> action) Equivalent ofStream.peek(Consumer).If
actionthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Type Parameters:
E- The exception type thrown byaction- Parameters:
exceptionClass- The exception class forEaction- seeStream.peek(Consumer)- Returns:
- see
Stream.peek(Consumer)
-
takeWhile
public <E extends Exception> ExStream<T> takeWhile(Class<E> exceptionClass, ExPredicate<? super T, ? extends E> predicate) Equivalent ofStream.takeWhile(Predicate).If
predicatethrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Type Parameters:
E- The exception type thrown bypredicate- Parameters:
exceptionClass- The exception class forEpredicate- seeStream.takeWhile(Predicate)- Returns:
- see
Stream.takeWhile(Predicate)
-
dropWhile
public <E extends Exception> ExStream<T> dropWhile(Class<E> exceptionClass, ExPredicate<? super T, ? extends E> predicate) 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.- Type Parameters:
E- The exception type thrown bypredicate- Parameters:
exceptionClass- The exception class forEpredicate- seeStream.dropWhile(Predicate)- Returns:
- see
Stream.dropWhile(Predicate)
-
forEach
public <E extends Exception> void forEach(Class<E> exceptionClass, ExConsumer<? super T, ? extends E> action) Equivalent ofStream.forEach(Consumer).If
actionthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Type Parameters:
E- The exception type thrown byaction- Parameters:
exceptionClass- The exception class forEaction- seeStream.forEach(Consumer)
-
forEachOrdered
public <E extends Exception> void forEachOrdered(Class<E> exceptionClass, ExConsumer<? super T, ? extends E> action) Equivalent ofStream.forEachOrdered(Consumer).If
actionthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Type Parameters:
E- The exception type thrown byaction- Parameters:
exceptionClass- The exception class forEaction- seeStream.forEachOrdered(Consumer)
-
reduce
public <E extends Exception> Optional<T> reduce(Class<E> exceptionClass, ExBinaryOperator<T, ? extends E> accumulator) Equivalent ofStream.reduce(BinaryOperator).If
accumulatorthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Type Parameters:
E- The exception type thrown byaccumulator- Parameters:
exceptionClass- The exception class forEaccumulator- seeStream.reduce(BinaryOperator)- Returns:
- see
Stream.reduce(BinaryOperator)
-
reduce
public <E extends Exception> T reduce(Class<E> exceptionClass, T identity, ExBinaryOperator<T, ? extends E> accumulator) Equivalent ofStream.reduce(Object, BinaryOperator).If
accumulatorthrows a checked exception, aExExceptionwill be thrown instead. This will have the original exception as itscause.- Type Parameters:
E- The exception type thrown byaccumulator- Parameters:
exceptionClass- The exception class forEidentity- seeStream.reduce(Object, BiFunction, BinaryOperator)accumulator- seeStream.reduce(Object, BinaryOperator)- Returns:
- see
Stream.reduce(Object, BinaryOperator)
-
reduce
public <U, E extends Exception> U reduce(Class<E> exceptionClass, U identity, ExBiFunction<U, ? super T, U, ? extends E> accumulator, ExBinaryOperator<U, ? extends E> 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 streamE- The exception type thrown byaccumulatororcombiner- Parameters:
exceptionClass- The exception class forEidentity- seeStream.reduce(Object, BiFunction, BinaryOperator)accumulator- seeStream.reduce(Object, BiFunction, BinaryOperator)combiner- seeStream.reduce(Object, BiFunction, BinaryOperator)- Returns:
- see
Stream.reduce(Object, BiFunction, BinaryOperator)
-
collect
public <R, E extends Exception> R collect(Class<E> exceptionClass, ExSupplier<R, ? extends E> supplier, ExBiConsumer<R, ? super T, ? extends E> accumulator, ExBiConsumer<R, R, ? extends E> 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 containerE- The exception type thrown bysupplier,accumulatororcombiner- Parameters:
exceptionClass- The exception class forEsupplier- seeStream.collect(Supplier, BiConsumer, BiConsumer)accumulator- seeStream.collect(Supplier, BiConsumer, BiConsumer)combiner- seeStream.collect(Supplier, BiConsumer, BiConsumer)- Returns:
- see
Stream.collect(Supplier, BiConsumer, BiConsumer)
-