[
https://issues.apache.org/jira/browse/SLING-2641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13488153#comment-13488153
]
Felix Meschberger commented on SLING-2641:
------------------------------------------
To be honest, I don't really like listChildren returning something different
than Iterator<Resource>. In fact I even fear breaking binary compatibility.
I would be ok with a new Iterable<Resource> getChildren method on the resource
and would think to not change the ResourceResolver (or also add a similar
getChildren method). The AbstractResource class can implement this method
really easily:
Iterable<Resource> getChildren() {
return new Iterable<Resource>() {
Iterator<Resource> iterator() {
return AbstractResource.this.listChildren();
}
}
}
Since we update the API (again) and increase the export version,
implementations of the Resource interface have to be updated (at least rebuilt)
anyway.
> Make listChildren() Iterable
> ----------------------------
>
> Key: SLING-2641
> URL: https://issues.apache.org/jira/browse/SLING-2641
> Project: Sling
> Issue Type: Improvement
> Components: API, General, ResourceResolver, Testing
> Affects Versions: API 2.2.4
> Reporter: Dan Klco
> Labels: features, noob, patch
> Attachments: SLING-2641-Resource-Iterator.diff
>
>
> When you call Resource.listChildren() or resourceResolver.listChildren() it
> returns a Iterator<Resource>, this is fine if you want to just iterate
> through the results using old-style while loops, but if you want to use
> enhanced loops, you are out of luck.
> I'm proposing adding an interface to return from these methods which extends
> both Iterator<Resource> and Iterable<Resource>. This will allow for using
> enhanced loops with the results of listChildren().
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira