In our code I often see code that (ugh) retrieves a component by id,
something like:
public class SomePanel extends Panel {
...
target.add(getPage().get("feedback"));
...
}
If we made MarkupContainer streamable, we could, in pseudo code, do
something like:
getPage().stream().filter(c->c.getId().equals("feedback")).findFirst();
Which is not better than getPage().get("feedback")
But it is more flexible checking for types, etc.
The implementation is not that complicated:
/**
* Returns a sequential {@code Stream} with the children of this
markup container
* as its source.
*
* @return a sequential {@code Stream} over the children of this
markup container
* @since 8.0
*/
public Stream<Component> stream()
{
return StreamSupport.stream(spliterator(), false);
}
Good idea?
Martijn