[
https://issues.apache.org/jira/browse/JENA-1956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17206132#comment-17206132
]
Andy Seaborne commented on JENA-1956:
-------------------------------------
I haven't thought about the "loop twice" implication of {{Iterable}}. It isn't
in the javadoc one way or the other, but certainly in java collections the
for-each is repeatable and {{ResultSet}} does have a bit of a collection feel.
Do you think {{stream()}} carries the same implication? We could add:
{noformat}
public default Stream<QuerySolution> stream() {
return Iter.asStream(this);
}
{noformat}
> ResultSet should implement Iterable
> -----------------------------------
>
> Key: JENA-1956
> URL: https://issues.apache.org/jira/browse/JENA-1956
> Project: Apache Jena
> Issue Type: Improvement
> Reporter: Jan Martin Keil
> Priority: Major
>
> The class {{ResultSet}} should implement {{Iterable<QuerySolution>}}. That
> would significantly ease query result processing. It would allow to write
> {code:java}
> for (QuerySolution result : QueryExecutionFactory.create(query,
> model).execSelect()) {
> …
> }
> {code}
> instead of
> {code:java}
> ResultSet results = QueryExecutionFactory.create(query, model).execSelect();
> while (results.hasNext()) {
> QuerySolution result = results.next();
> …
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)