Package io.jmix.ui.model
Interface CollectionContainer<E>
- All Superinterfaces:
InstanceContainer<E>
- All Known Subinterfaces:
CollectionPropertyContainer<E>
,KeyValueCollectionContainer
- All Known Implementing Classes:
CollectionContainerImpl
,CollectionPropertyContainerImpl
,KeyValueCollectionContainerImpl
Container that holds a collection of entity instances.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Event sent on changes in the container items collection - adding, removing, replacing elements.static enum
Nested classes/interfaces inherited from interface io.jmix.ui.model.InstanceContainer
InstanceContainer.ItemChangeEvent<T>, InstanceContainer.ItemPropertyChangeEvent<T>
-
Method Summary
Modifier and TypeMethodDescriptionAdds listener toCollectionContainer.CollectionChangeEvent
.boolean
containsItem
(Object entityOrId) Returns true if the given entity exists in the container.Returns entity by its id.int
getItemIndex
(Object entityOrId) Returns the index in the items list of the given entity or -1 if there is no such entity.getItemOrNull
(Object entityId) Returns entity by its id or null if the container doesn't have an entity with the given id.getItems()
Returns immutable list of contained entities.Returns mutable list of contained entities.Returns sorter object currently set for the container.void
replaceItem
(E entity) If the item with the same id exists in the container, it is replaced with the given instance.void
setItems
(Collection<E> entities) Sets a collection of entities to the container.void
Sets sorter object.void
Enables all event listeners.Methods inherited from interface io.jmix.ui.model.InstanceContainer
addItemChangeListener, addItemPropertyChangeListener, getEntityMetaClass, getFetchPlan, getItem, getItemOrNull, getView, mute, setFetchPlan, setItem, setView, unmute
-
Method Details
-
getItems
Returns immutable list of contained entities. -
setItems
Sets a collection of entities to the container. -
getMutableItems
Returns mutable list of contained entities. Changes in the list produceCollectionContainer.CollectionChangeEvent
. -
getItem
Returns entity by its id.- Throws:
IllegalArgumentException
- if the container doesn't have an entity with the given id
-
getItemOrNull
Returns entity by its id or null if the container doesn't have an entity with the given id. -
getItemIndex
Returns the index in the items list of the given entity or -1 if there is no such entity.- Parameters:
entityOrId
- entity instance or its id
-
containsItem
Returns true if the given entity exists in the container.- Parameters:
entityOrId
- entity instance or its id
-
replaceItem
If the item with the same id exists in the container, it is replaced with the given instance. If not, the given instance is added to the items list.Sends
CollectionContainer.CollectionChangeEvent
of theSET_ITEM
orADD_ITEMS
type. -
getSorter
Returns sorter object currently set for the container. -
setSorter
Sets sorter object. -
unmute
Enables all event listeners. Events fired on this call depend on the passedmode
.- Parameters:
mode
- mode
-
addCollectionChangeListener
Subscription addCollectionChangeListener(Consumer<CollectionContainer.CollectionChangeEvent<E>> listener) Adds listener toCollectionContainer.CollectionChangeEvent
.
-