Skip to content

Commit c8efa5a

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 c8efa5a

File tree

1 file changed

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

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
package io.vertx.sqlclient;
1919

2020
import io.vertx.codegen.annotations.VertxGen;
21+
import io.vertx.codegen.annotations.GenIgnore;
22+
23+
import java.util.stream.Stream;
24+
import java.util.stream.StreamSupport;
2125

2226
/**
2327
* The execution result of the row set of a query provided as {@code <R>}, commonly used as a {@code RowSet<Row>}.
@@ -32,4 +36,11 @@ public interface RowSet<R> extends Iterable<R>, SqlResult<RowSet<R>> {
3236
@Override
3337
RowSet<R> next();
3438

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

0 commit comments

Comments
 (0)