[ 
https://issues.apache.org/jira/browse/COMMONSRDF-12?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14490328#comment-14490328
 ] 

Stian Soiland-Reyes commented on COMMONSRDF-12:
-----------------------------------------------

Ah, that is a great middle ground and less intrusive, I'll run with that.



> Graph to be Iterable
> --------------------
>
>                 Key: COMMONSRDF-12
>                 URL: https://issues.apache.org/jira/browse/COMMONSRDF-12
>             Project: Apache Commons RDF
>          Issue Type: New Feature
>            Reporter: Stian Soiland-Reyes
>            Assignee: Stian Soiland-Reyes
>
> A Graph is a collection of triples, yet it does not support the Iterable 
> interface, and thus can't be used in a classic for-each loop like:
> {code}
>         for (Triple t : graph) {
>             System.out.println(t);
>         }
> {code}
> instead you are forced to use .getTriples() and either .sequential().forEach, 
> or the awkward casting with ::iterator
> http://stackoverflow.com/questions/20129762/why-does-streamt-not-implement-iterablet
> Note that Stream is not Iterable, as it can only be iterated over once.. (I 
> often find my self adding a function like iterable() to work around such 
> cases).
> My proposal is simply to add the interface Iterable and have a default 
> implementation that calls getTriples().iterator().
> It could be that there are other solutions that also work with the filtered 
> getTriples() - e.g. some kind of Collector that is iterable?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to