Skip to content

Latest commit

 

History

History
37 lines (30 loc) · 1.01 KB

Readme.md

File metadata and controls

37 lines (30 loc) · 1.01 KB

ExStream

A wrapper interface for Stream with exception support.

Usage

Given some Stream<T> named source

ExStream<T> exStream = ExStreamBuilder.of(source)

Now one can use with throwable functions.

All terminal operations will throw ExStreamException with the cause being the original exception thrown in the exceptional method.

exStream.exFilter(Functions::someExceptionalPredicate)
        .exMap(Functions::someExceptionalMapper)
        .exReduce(Functions::nonExceptionalReducingFunction)
        .exFindFirst()

Good old Collectors work

List<T> list = exStream.exCollect(Collectors.toList())

It's possible to obtain a Stream instance with exStream.toStream(). This instance can throw ExStreamRuntimeException on any terminal operation.

Maven coordinates

You can use a released version from maven repositories

<dependency>
    <groupId>io.github.pak3nuh.util</groupId>
    <artifactId>exstream</artifactId>
    <version>LATEST</version>
</dependency>