Stream Utility

The helper class for working with Java 8 streams

License

License

GroupId

GroupId

org.jmmo
ArtifactId

ArtifactId

stream-util
Last Version

Last Version

1.13
Release Date

Release Date

Type

Type

jar
Description

Description

Stream Utility
The helper class for working with Java 8 streams
Project URL

Project URL

https://github.com/Megaprog/stream-util
Source Code Management

Source Code Management

https://github.com/Megaprog/stream-util

Download stream-util

How to add to project

<!-- https://jarcasting.com/artifacts/org.jmmo/stream-util/ -->
<dependency>
    <groupId>org.jmmo</groupId>
    <artifactId>stream-util</artifactId>
    <version>1.13</version>
</dependency>
// https://jarcasting.com/artifacts/org.jmmo/stream-util/
implementation 'org.jmmo:stream-util:1.13'
// https://jarcasting.com/artifacts/org.jmmo/stream-util/
implementation ("org.jmmo:stream-util:1.13")
'org.jmmo:stream-util:jar:1.13'
<dependency org="org.jmmo" name="stream-util" rev="1.13">
  <artifact name="stream-util" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jmmo', module='stream-util', version='1.13')
)
libraryDependencies += "org.jmmo" % "stream-util" % "1.13"
[org.jmmo/stream-util "1.13"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.13.1
org.hamcrest : hamcrest-junit jar 2.0.0.0

Project Modules

There are no modules declared in this project.

Maven Central

Stream Utility

The helper class for working with Java 8 streams. It allows to create streams from Optional, from Supplier, from Matcher etc.

How to use it?

To create stream from supplier function:

Stream<Object> stream = StreamUtil.supply(() -> hasData() ? read() : null);

To create files stream (all files in directory and subdirectories):

Stream<Path> files = StreamUtil.files("myDirectory");

To wrap lambdas throws checked exceptions:

void method(int a, String b) throws IOException, InterruptedException { }

boolean isSomething(int a, String b) throws IOException, TimeoutException { return true; }

public void testUnchecked_Throw() throws Exception {
    Stream.of(1)
        .filter(i1 -> StreamUtil.unchecked(() -> isSomething(i1, "1")))
        .forEach(i2 -> StreamUtil.unchecked(() -> method(i2, "2")));
}

To wrap lambdas throws InterruptedException:

StreamUtil.uninterrupted(() -> Thread.sleep(1));

To logging expensive expressions:

log.debug("Debugging of {}", LazyToString.of(() -> "some expensive expression"));

Versions

Version
1.13
1.12
1.11
1.10
1.9
1.8
1.7.1
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1.0