addAll() on

Hi all,

why is there no addAll(Collection<?> items) method on the Container interface but removeAllItems() and addItem() are declared in the interface?

You can’t usually add externally created items to a container. Some containers allow that in some way, such as BeanItemContainer, but not quite. BIC actually allows adding beans, not items (which implement the Item interface).

So, the addItem() defined in the Container interface asks the container to create an item with a given item ID, you can’t (in any of the built-in containers) pass the actual item to it as parameter. Some use cases can be a bit confusing in that respect, as the item ID, which is passed, is used as the actual item data.