diff --git a/README.md b/README.md index 20604d3..d2fd86f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Gatherers4j -A library of useful [Stream Gatherers](https://openjdk.org/jeps/473) (custom intermediate operations) for Java 23+. +A library of useful [Stream Gatherers](https://openjdk.org/jeps/485) (custom intermediate operations) for Java 23+. # Installing diff --git a/src/main/java/com/ginsberg/gatherers4j/GathererUtils.java b/src/main/java/com/ginsberg/gatherers4j/GathererUtils.java index 5c4bb3e..6eddfb2 100644 --- a/src/main/java/com/ginsberg/gatherers4j/GathererUtils.java +++ b/src/main/java/com/ginsberg/gatherers4j/GathererUtils.java @@ -17,21 +17,10 @@ import org.jspecify.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; - abstract class GathererUtils { final static long NANOS_PER_MILLISECOND = 1_000_000; - - static List listOfNullables(final @Nullable INPUT left, final @Nullable INPUT right) { - final List list = new ArrayList<>(); - list.add(left); - list.add(right); - return list; - } - static void mustNotBeNull(final @Nullable Object subject, final String message) { if (subject == null) { throw new IllegalArgumentException(message); diff --git a/src/main/java/com/ginsberg/gatherers4j/ZipWithNextGatherer.java b/src/main/java/com/ginsberg/gatherers4j/ZipWithNextGatherer.java index eb328d8..767fde3 100644 --- a/src/main/java/com/ginsberg/gatherers4j/ZipWithNextGatherer.java +++ b/src/main/java/com/ginsberg/gatherers4j/ZipWithNextGatherer.java @@ -18,12 +18,11 @@ import org.jspecify.annotations.Nullable; +import java.util.Arrays; import java.util.List; import java.util.function.Supplier; import java.util.stream.Gatherer; -import static com.ginsberg.gatherers4j.GathererUtils.listOfNullables; - public class ZipWithNextGatherer implements Gatherer, List> { @@ -42,7 +41,7 @@ public Integrator, INPUT, List> integrator() { if (!state.hasValue) { state.hasValue = true; } else { - downstream.push(listOfNullables(state.value, element)); + downstream.push(Arrays.asList(state.value, element)); } state.value = element; return !downstream.isRejecting(); diff --git a/src/test/java/com/ginsberg/gatherers4j/GathererUtilsTest.java b/src/test/java/com/ginsberg/gatherers4j/GathererUtilsTest.java index fcd8387..3b97752 100644 --- a/src/test/java/com/ginsberg/gatherers4j/GathererUtilsTest.java +++ b/src/test/java/com/ginsberg/gatherers4j/GathererUtilsTest.java @@ -19,9 +19,9 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import java.util.Arrays; import java.util.List; -import static com.ginsberg.gatherers4j.GathererUtils.listOfNullables; import static com.ginsberg.gatherers4j.GathererUtils.mustNotBeNull; import static org.assertj.core.api.Assertions.*; @@ -37,7 +37,7 @@ void containsNulls() { final String right = null; // Act - final List output = listOfNullables(left, right); + final List output = Arrays.asList(left, right); // Assert assertThat(output).isNotNull().hasSize(2).containsExactly(left, right); @@ -50,7 +50,7 @@ void containsNonNulls() { final String right = "B"; // Act - final List output = listOfNullables(left, right); + final List output = Arrays.asList(left, right); // Assert assertThat(output).isNotNull().hasSize(2).containsExactly(left, right); diff --git a/src/test/java/com/ginsberg/gatherers4j/ZipWithNextGathererTest.java b/src/test/java/com/ginsberg/gatherers4j/ZipWithNextGathererTest.java index a036f70..1611796 100644 --- a/src/test/java/com/ginsberg/gatherers4j/ZipWithNextGathererTest.java +++ b/src/test/java/com/ginsberg/gatherers4j/ZipWithNextGathererTest.java @@ -18,10 +18,10 @@ import org.junit.jupiter.api.Test; +import java.util.Arrays; import java.util.List; import java.util.stream.Stream; -import static com.ginsberg.gatherers4j.GathererUtils.listOfNullables; import static org.assertj.core.api.Assertions.assertThat; class ZipWithNextGathererTest { @@ -60,9 +60,9 @@ void zipWithNextIncludingNulls() { // Assert assertThat(output) .containsExactly( - listOfNullables("A", null), - listOfNullables(null, "C"), - listOfNullables("C", null) + Arrays.asList("A", null), + Arrays.asList(null, "C"), + Arrays.asList("C", null) ); }