Skip to content

Commit

Permalink
Update README (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Oct 8, 2024
1 parent 7c3d185 commit c49ee0f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>)`
- `MoreGatherers.zip(Iterator<T>)`
- `MoreGatherers.zip(Stream<T>)`
- `MoreGatherers.distinctBy(Function<T, R>)`
7 changes: 4 additions & 3 deletions src/test/java/com/pivovarit/gatherers/ZipCollectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
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;

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"),
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/com/pivovarit/gatherers/ZipIteratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@

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;

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"),
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/com/pivovarit/gatherers/ZipStreamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@

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;

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"),
Expand Down

0 comments on commit c49ee0f

Please sign in to comment.