From f468e89e97d4a4ee22d826dd4fbab9a2e04fab0f Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Wed, 7 May 2025 14:43:51 +0200 Subject: [PATCH] Provide a RowSet#stream(). Motivation: RowSet extends Iterable to provide iterations over the rows contained in the set. We should support returning a java.util.stream.Stream as well. Changes: Add a stream() default method to RowSet that returns a java.util.stream.Stream. --- .../src/main/java/io/vertx/sqlclient/RowSet.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vertx-sql-client/src/main/java/io/vertx/sqlclient/RowSet.java b/vertx-sql-client/src/main/java/io/vertx/sqlclient/RowSet.java index 5c012ef2b..749e099be 100644 --- a/vertx-sql-client/src/main/java/io/vertx/sqlclient/RowSet.java +++ b/vertx-sql-client/src/main/java/io/vertx/sqlclient/RowSet.java @@ -18,6 +18,10 @@ package io.vertx.sqlclient; import io.vertx.codegen.annotations.VertxGen; +import io.vertx.codegen.annotations.GenIgnore; + +import java.util.stream.Stream; +import java.util.stream.StreamSupport; /** * The execution result of the row set of a query provided as {@code }, commonly used as a {@code RowSet}. @@ -32,4 +36,11 @@ public interface RowSet extends Iterable, SqlResult> { @Override RowSet next(); + /** + * @return a stream of rows + */ + @GenIgnore(GenIgnore.PERMITTED_TYPE) + default Stream stream() { + return StreamSupport.stream(spliterator(), false); + } }