From c49ee0f8b01ea1bedf1ec4081e89ca68c6c3d5f9 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Tue, 8 Oct 2024 08:57:13 +0200 Subject: [PATCH] Update README (#15) --- README.md | 11 ++++++++++- .../com/pivovarit/gatherers/ZipCollectionTest.java | 7 ++++--- .../java/com/pivovarit/gatherers/ZipIteratorTest.java | 7 ++++--- .../java/com/pivovarit/gatherers/ZipStreamTest.java | 7 ++++--- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 50d26a4..ca058a2 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,14 @@ Missing Stream API functionality you always longed for - provided via `Gatherers [![Stargazers over time](https://starchart.cc/pivovarit/more-gatherers.svg?variant=adaptive)](https://starchart.cc/pivovarit/more-gatherers) -## Project is under intense development and will be released alongside Java 24, when Stream Gatherers go GA +## Project is under intense development and will be released alongside Java 24, when Stream Gatherers go GA (hopefully) +### Overview + +Java's Stream API is a powerful tool for processing collections of data. However, it lacks some functionality that could make it even more powerful. This library aims to fill that gap by providing a set of `Gatherers` that can be used to collect data from a stream in a more flexible way. + +Provided `Gatherers`: +- `MoreGatherers.zip(Collection)` +- `MoreGatherers.zip(Iterator)` +- `MoreGatherers.zip(Stream)` +- `MoreGatherers.distinctBy(Function)` diff --git a/src/test/java/com/pivovarit/gatherers/ZipCollectionTest.java b/src/test/java/com/pivovarit/gatherers/ZipCollectionTest.java index efd7ccc..095bd56 100644 --- a/src/test/java/com/pivovarit/gatherers/ZipCollectionTest.java +++ b/src/test/java/com/pivovarit/gatherers/ZipCollectionTest.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.stream.Stream; +import static com.pivovarit.gatherers.MoreGatherers.zip; import static java.util.Map.entry; import static org.assertj.core.api.Assertions.assertThat; @@ -12,17 +13,17 @@ class ZipCollectionTest { @Test void shouldZipEmpty() { - assertThat(Stream.empty().gather(MoreGatherers.zip(List.of(1, 2, 3)))).isEmpty(); + assertThat(Stream.empty().gather(zip(List.of(1, 2, 3)))).isEmpty(); } @Test void shouldZipWithEmpty() { - assertThat(Stream.of(1, 2, 3).gather(MoreGatherers.zip(List.of()))).isEmpty(); + assertThat(Stream.of(1, 2, 3).gather(zip(List.of()))).isEmpty(); } @Test void shouldZip() { - assertThat(Stream.of(1, 2, 3).gather(MoreGatherers.zip(List.of("a", "b", "c", "d")))) + assertThat(Stream.of(1, 2, 3).gather(zip(List.of("a", "b", "c", "d")))) .containsExactly( entry(1, "a"), entry(2, "b"), diff --git a/src/test/java/com/pivovarit/gatherers/ZipIteratorTest.java b/src/test/java/com/pivovarit/gatherers/ZipIteratorTest.java index 398a70c..60b1296 100644 --- a/src/test/java/com/pivovarit/gatherers/ZipIteratorTest.java +++ b/src/test/java/com/pivovarit/gatherers/ZipIteratorTest.java @@ -4,6 +4,7 @@ import java.util.stream.Stream; +import static com.pivovarit.gatherers.MoreGatherers.zip; import static java.util.Map.entry; import static org.assertj.core.api.Assertions.assertThat; @@ -11,17 +12,17 @@ class ZipIteratorTest { @Test void shouldZipEmpty() { - assertThat(Stream.empty().gather(MoreGatherers.zip(Stream.of(1, 2, 3).iterator()))).isEmpty(); + assertThat(Stream.empty().gather(zip(Stream.of(1, 2, 3).iterator()))).isEmpty(); } @Test void shouldZipWithEmpty() { - assertThat(Stream.of(1, 2, 3).gather(MoreGatherers.zip(Stream.of().iterator()))).isEmpty(); + assertThat(Stream.of(1, 2, 3).gather(zip(Stream.of().iterator()))).isEmpty(); } @Test void shouldZip() { - assertThat(Stream.of(1, 2, 3).gather(MoreGatherers.zip(Stream.of("a", "b", "c", "d").iterator()))) + assertThat(Stream.of(1, 2, 3).gather(zip(Stream.of("a", "b", "c", "d").iterator()))) .containsExactly( entry(1, "a"), entry(2, "b"), diff --git a/src/test/java/com/pivovarit/gatherers/ZipStreamTest.java b/src/test/java/com/pivovarit/gatherers/ZipStreamTest.java index aaeafba..1c0992c 100644 --- a/src/test/java/com/pivovarit/gatherers/ZipStreamTest.java +++ b/src/test/java/com/pivovarit/gatherers/ZipStreamTest.java @@ -4,6 +4,7 @@ import java.util.stream.Stream; +import static com.pivovarit.gatherers.MoreGatherers.*; import static java.util.Map.entry; import static org.assertj.core.api.Assertions.assertThat; @@ -11,17 +12,17 @@ class ZipStreamTest { @Test void shouldZipEmpty() { - assertThat(Stream.empty().gather(MoreGatherers.zip(Stream.of(1, 2, 3)))).isEmpty(); + assertThat(Stream.empty().gather(zip(Stream.of(1, 2, 3)))).isEmpty(); } @Test void shouldZipWithEmpty() { - assertThat(Stream.of(1, 2, 3).gather(MoreGatherers.zip(Stream.of()))).isEmpty(); + assertThat(Stream.of(1, 2, 3).gather(zip(Stream.of()))).isEmpty(); } @Test void shouldZip() { - assertThat(Stream.of(1, 2, 3).gather(MoreGatherers.zip(Stream.of("a", "b", "c", "d")))) + assertThat(Stream.of(1, 2, 3).gather(zip(Stream.of("a", "b", "c", "d")))) .containsExactly( entry(1, "a"), entry(2, "b"),