This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
commit f2ebda7cc7aefa790004c40979183ecf767ec6b9 Author: Andy Seaborne <[email protected]> AuthorDate: Fri Jul 4 12:04:49 2025 +0100 Add concat(Stream,Stream); handled nulls --- .../src/main/java/org/apache/jena/atlas/lib/StreamOps.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/StreamOps.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/StreamOps.java index 0d55e0f731..9fc2793dbb 100644 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/StreamOps.java +++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/StreamOps.java @@ -59,6 +59,18 @@ public class StreamOps { return first(collection.stream()); } + /** + * Join two streams. This is the function to accumulate stream from a loop. + * If either stream is null, then return the other which may also be null. + */ + public static <X> Stream<X> concat(Stream<X> stream1, Stream<X> stream2) { + if ( stream1 == null ) + return stream2; + if ( stream2 == null ) + return stream1; + return Stream.concat(stream1, stream2); + } + /** Debug : print stream. * This operation prints the whole stream at the point it is used, * and then returns a new stream of the same elements.
