Stream<INPUT>
to the end of the current stream, in order.
+ *
+ * @param concatThis A non-null Stream<INPUT>
instance to concatenate.
+ */
+ public static ConcatenationGatherer concat(final Stream concatThis) {
+ return new ConcatenationGatherer<>(concatThis);
+ }
+
/**
* Given a stream of objects, filter the objects such that any consecutively appearing
* after the first one are dropped.
@@ -162,7 +171,7 @@ public static BigDecimalSimpleMovingAverageGatherermappingFunction
and looking back `windowSize` number of elements.
*
* @param mappingFunction The non-null function to map from <INPUT>
to BigDecimal
.
- * @param windowSize The number of elements to average, must be greater than 1.
+ * @param windowSize The number of elements to average, must be greater than 1.
*/
public static BigDecimalSimpleMovingAverageGatherer simpleMovingAverageBy(
final Function mappingFunction,
diff --git a/src/test/java/com/ginsberg/gatherers4j/ConcatenationGathererTest.java b/src/test/java/com/ginsberg/gatherers4j/ConcatenationGathererTest.java
new file mode 100644
index 0000000..b261a37
--- /dev/null
+++ b/src/test/java/com/ginsberg/gatherers4j/ConcatenationGathererTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2024 Todd Ginsberg
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ginsberg.gatherers4j;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.stream.Stream;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+class ConcatenationGathererTest {
+
+ @Test
+ void additionalStreamCannotBeNull() {
+ assertThatThrownBy(() ->
+ Stream.of("A").gather(Gatherers4j.concat(Stream.of("1")).concat(null))
+ ).isExactlyInstanceOf(IllegalArgumentException.class);
+ }
+
+ @Test
+ void allowsEmptyConcat() {
+ // Arrange
+ final Stream