Skip to content

Commit 5d1fc4c

Browse files
committed
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.
1 parent eb78c7f commit 5d1fc4c

File tree

1 file changed

+9
-0
lines changed
  • vertx-sql-client/src/main/java/io/vertx/sqlclient

1 file changed

+9
-0
lines changed

vertx-sql-client/src/main/java/io/vertx/sqlclient/RowSet.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
import io.vertx.codegen.annotations.VertxGen;
2121

22+
import java.util.stream.Stream;
23+
import java.util.stream.StreamSupport;
24+
2225
/**
2326
* The execution result of the row set of a query provided as {@code <R>}, commonly used as a {@code RowSet<Row>}.
2427
* Using a collector query might provide a different result.
@@ -32,4 +35,10 @@ public interface RowSet<R> extends Iterable<R>, SqlResult<RowSet<R>> {
3235
@Override
3336
RowSet<R> next();
3437

38+
/**
39+
* @return a stream of rows
40+
*/
41+
default Stream<R> stream() {
42+
return StreamSupport.stream(spliterator(), false);
43+
}
3544
}

0 commit comments

Comments
 (0)