On Sun, 12 Apr 2026 18:14:40 GMT, Marius Hanl <[email protected]> wrote:
>> Charlie Schlosser has updated the pull request incrementally with two
>> additional commits since the last revision:
>>
>> - copyright
>> - its not necessary
>
> modules/javafx.controls/src/main/java/javafx/scene/control/TreeUtil.java line
> 162:
>
>> 160: */
>> 161: static <T> Iterable<TreeItem<T>> getItems(TreeItem<T> root) {
>> 162: return () -> new Iterator<>() {
>
> Does it make sense to return `Iterator` directly - or do we have any
> advantage with `Iterable` (given that we always call `iterator()` directly)
I decided on `Iterable` because it implies a collection of objects, whereas
`Iterator` implies a position within that collection. Doesn't matter either
way.
You are correct that the only current use is to create a stateful iterator, but
it could convenient to do something like `for(TreeItem item :
TreeUtil.getItems(root))`, or starting a search at some other node
`for(TreeItem item : TreeUtil.getItems(child))`.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2142#discussion_r3070359570