Package io.jmix.flowui.model.impl
Class CollectionContainerImpl<E>
java.lang.Object
io.jmix.flowui.model.impl.InstanceContainerImpl<E>
io.jmix.flowui.model.impl.CollectionContainerImpl<E>
- All Implemented Interfaces:
CollectionContainer<E>
,HasLoader
,ItemPropertyChangeNotifier
,InstanceContainer<E>
- Direct Known Subclasses:
CollectionPropertyContainerImpl
,KeyValueCollectionContainerImpl
public class CollectionContainerImpl<E>
extends InstanceContainerImpl<E>
implements CollectionContainer<E>
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.flowui.model.CollectionContainer
CollectionContainer.CollectionChangeEvent<T>, CollectionContainer.UnmuteEventsMode
Nested classes/interfaces inherited from interface io.jmix.flowui.model.InstanceContainer
InstanceContainer.ItemChangeEvent<T>, InstanceContainer.ItemPropertyChangeEvent<T>
-
Field Summary
Fields inherited from class io.jmix.flowui.model.impl.InstanceContainerImpl
entityMetaClass, events, fetchPlan, item, listener, listenersEnabled, loader, metadata
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds listener toCollectionContainer.CollectionChangeEvent
.protected void
addToCollection
(E entity) protected void
attachListener
(Collection<E> entities) protected void
protected void
boolean
containsItem
(Object entityOrId) Returns true if the given entity exists in the container.protected void
detachListener
(Collection<E> entities) protected void
fireCollectionChanged
(CollectionChangeType type, Collection<? extends E> changes) 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
protected void
replaceInCollection
(int idx, E entity) void
replaceItem
(E entity) If the item with the same id exists in the container, it is replaced with the given instance.void
Sets the given entity instance to the container.void
setItems
(Collection<E> entities) Sets a collection of entities to the container.void
Sets sorter object.toString()
void
Enables all event listeners.Methods inherited from class io.jmix.flowui.model.impl.InstanceContainerImpl
addItemChangeListener, addItemPropertyChangeListener, attachListener, detachListener, fireItemChanged, getEntityMetaClass, getFetchPlan, getItem, getItemOrNull, getLoader, mute, setFetchPlan, setLoader, unmute
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.jmix.flowui.model.InstanceContainer
addItemChangeListener, addItemPropertyChangeListener, getEntityMetaClass, getFetchPlan, getItem, getItemOrNull, getView, mute, setFetchPlan, setView, unmute
-
Field Details
-
metadataTools
-
collection
-
idMap
-
sorter
-
-
Constructor Details
-
CollectionContainerImpl
-
-
Method Details
-
setItem
Description copied from interface:InstanceContainer
Sets the given entity instance to the container.- Specified by:
setItem
in interfaceInstanceContainer<E>
- Overrides:
setItem
in classInstanceContainerImpl<E>
-
getItems
Description copied from interface:CollectionContainer
Returns immutable list of contained entities.- Specified by:
getItems
in interfaceCollectionContainer<E>
-
getMutableItems
Description copied from interface:CollectionContainer
Returns mutable list of contained entities. Changes in the list produceCollectionContainer.CollectionChangeEvent
.- Specified by:
getMutableItems
in interfaceCollectionContainer<E>
-
setItems
Description copied from interface:CollectionContainer
Sets a collection of entities to the container.- Specified by:
setItems
in interfaceCollectionContainer<E>
-
getItem
Description copied from interface:CollectionContainer
Returns entity by its id.- Specified by:
getItem
in interfaceCollectionContainer<E>
-
getItemOrNull
Description copied from interface:CollectionContainer
Returns entity by its id or null if the container doesn't have an entity with the given id.- Specified by:
getItemOrNull
in interfaceCollectionContainer<E>
-
getItemIndex
Description copied from interface:CollectionContainer
Returns the index in the items list of the given entity or -1 if there is no such entity.- Specified by:
getItemIndex
in interfaceCollectionContainer<E>
- Parameters:
entityOrId
- entity instance or its id
-
containsItem
Description copied from interface:CollectionContainer
Returns true if the given entity exists in the container.- Specified by:
containsItem
in interfaceCollectionContainer<E>
- Parameters:
entityOrId
- entity instance or its id
-
replaceItem
Description copied from interface:CollectionContainer
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.- Specified by:
replaceItem
in interfaceCollectionContainer<E>
-
replaceInCollection
-
addToCollection
-
addCollectionChangeListener
public Subscription addCollectionChangeListener(Consumer<CollectionContainer.CollectionChangeEvent<E>> listener) Description copied from interface:CollectionContainer
Adds listener toCollectionContainer.CollectionChangeEvent
.- Specified by:
addCollectionChangeListener
in interfaceCollectionContainer<E>
-
getSorter
Description copied from interface:CollectionContainer
Returns sorter object currently set for the container.- Specified by:
getSorter
in interfaceCollectionContainer<E>
-
setSorter
Description copied from interface:CollectionContainer
Sets sorter object.- Specified by:
setSorter
in interfaceCollectionContainer<E>
-
unmute
Description copied from interface:CollectionContainer
Enables all event listeners. Events fired on this call depend on the passedmode
.- Specified by:
unmute
in interfaceCollectionContainer<E>
- Parameters:
mode
- mode
-
itemPropertyChanged
- Specified by:
itemPropertyChanged
in interfaceItemPropertyChangeNotifier
- Overrides:
itemPropertyChanged
in classInstanceContainerImpl<E>
-
fireCollectionChanged
-
attachListener
-
detachListener
-
buildIdMap
protected void buildIdMap() -
clearItemIfNotExists
protected void clearItemIfNotExists() -
toString
- Overrides:
toString
in classInstanceContainerImpl<E>
-