Package io.jmix.ui.model.impl
Class CollectionContainerImpl<E>
java.lang.Object
io.jmix.ui.model.impl.InstanceContainerImpl<E>
io.jmix.ui.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.ui.model.CollectionContainer
CollectionContainer.CollectionChangeEvent<T>, CollectionContainer.UnmuteEventsModeNested classes/interfaces inherited from interface io.jmix.ui.model.InstanceContainer
InstanceContainer.ItemChangeEvent<T>, InstanceContainer.ItemPropertyChangeEvent<T> -
Field Summary
FieldsFields inherited from class io.jmix.ui.model.impl.InstanceContainerImpl
entityMetaClass, events, fetchPlan, item, listener, listenersEnabled, loader, metadata -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds listener toCollectionContainer.CollectionChangeEvent.protected voidaddToCollection(E entity) protected voidattachListener(Collection<E> entities) protected voidprotected voidbooleancontainsItem(Object entityOrId) Returns true if the given entity exists in the container.protected voiddetachListener(Collection<E> entities) protected voidfireCollectionChanged(CollectionChangeType type, Collection<? extends E> changes) Returns entity by its id.intgetItemIndex(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.voidprotected voidreplaceInCollection(int idx, E entity) voidreplaceItem(E entity) If the item with the same id exists in the container, it is replaced with the given instance.voidSets the given entity instance to the container.voidsetItems(Collection<E> entities) Sets a collection of entities to the container.voidSets sorter object.toString()voidEnables all event listeners.Methods inherited from class io.jmix.ui.model.impl.InstanceContainerImpl
addItemChangeListener, addItemPropertyChangeListener, attachListener, detachListener, fireItemChanged, getEntityMetaClass, getFetchPlan, getItem, getItemOrNull, getLoader, mute, setFetchPlan, setLoader, unmuteMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.jmix.ui.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:InstanceContainerSets the given entity instance to the container.- Specified by:
setItemin interfaceInstanceContainer<E>- Overrides:
setItemin classInstanceContainerImpl<E>
-
getItems
Description copied from interface:CollectionContainerReturns immutable list of contained entities.- Specified by:
getItemsin interfaceCollectionContainer<E>
-
getMutableItems
Description copied from interface:CollectionContainerReturns mutable list of contained entities. Changes in the list produceCollectionContainer.CollectionChangeEvent.- Specified by:
getMutableItemsin interfaceCollectionContainer<E>
-
setItems
Description copied from interface:CollectionContainerSets a collection of entities to the container.- Specified by:
setItemsin interfaceCollectionContainer<E>
-
getItem
Description copied from interface:CollectionContainerReturns entity by its id.- Specified by:
getItemin interfaceCollectionContainer<E>
-
getItemOrNull
Description copied from interface:CollectionContainerReturns entity by its id or null if the container doesn't have an entity with the given id.- Specified by:
getItemOrNullin interfaceCollectionContainer<E>
-
getItemIndex
Description copied from interface:CollectionContainerReturns the index in the items list of the given entity or -1 if there is no such entity.- Specified by:
getItemIndexin interfaceCollectionContainer<E>- Parameters:
entityOrId- entity instance or its id
-
containsItem
Description copied from interface:CollectionContainerReturns true if the given entity exists in the container.- Specified by:
containsItemin interfaceCollectionContainer<E>- Parameters:
entityOrId- entity instance or its id
-
replaceItem
Description copied from interface:CollectionContainerIf 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.CollectionChangeEventof theSET_ITEMorADD_ITEMStype.- Specified by:
replaceItemin interfaceCollectionContainer<E>
-
replaceInCollection
-
addToCollection
-
addCollectionChangeListener
public Subscription addCollectionChangeListener(Consumer<CollectionContainer.CollectionChangeEvent<E>> listener) Description copied from interface:CollectionContainerAdds listener toCollectionContainer.CollectionChangeEvent.- Specified by:
addCollectionChangeListenerin interfaceCollectionContainer<E>
-
getSorter
Description copied from interface:CollectionContainerReturns sorter object currently set for the container.- Specified by:
getSorterin interfaceCollectionContainer<E>
-
setSorter
Description copied from interface:CollectionContainerSets sorter object.- Specified by:
setSorterin interfaceCollectionContainer<E>
-
unmute
Description copied from interface:CollectionContainerEnables all event listeners. Events fired on this call depend on the passedmode.- Specified by:
unmutein interfaceCollectionContainer<E>- Parameters:
mode- mode
-
itemPropertyChanged
- Specified by:
itemPropertyChangedin interfaceItemPropertyChangeNotifier- Overrides:
itemPropertyChangedin classInstanceContainerImpl<E>
-
fireCollectionChanged
-
attachListener
-
detachListener
-
buildIdMap
protected void buildIdMap() -
clearItemIfNotExists
protected void clearItemIfNotExists() -
toString
- Overrides:
toStringin classInstanceContainerImpl<E>
-