public class CollectionContainerImpl<E> extends InstanceContainerImpl<E> implements CollectionContainer<E>
CollectionContainer.CollectionChangeEvent<T>, CollectionContainer.UnmuteEventsModeInstanceContainer.ItemChangeEvent<T>, InstanceContainer.ItemPropertyChangeEvent<T>| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<E> |
collection |
protected java.util.Map<IndexKey,java.lang.Integer> |
idMap |
protected io.jmix.core.MetadataTools |
metadataTools |
protected Sorter |
sorter |
entityMetaClass, events, fetchPlan, item, listener, listenersEnabled, loader, metadata| Constructor and Description |
|---|
CollectionContainerImpl(io.jmix.core.metamodel.model.MetaClass metaClass) |
| Modifier and Type | Method and Description |
|---|---|
io.jmix.core.common.event.Subscription |
addCollectionChangeListener(java.util.function.Consumer<CollectionContainer.CollectionChangeEvent<E>> listener)
Adds listener to
CollectionContainer.CollectionChangeEvent. |
protected void |
addToCollection(E entity) |
protected void |
attachListener(java.util.Collection<E> entities) |
protected void |
buildIdMap() |
protected void |
clearItemIfNotExists() |
boolean |
containsItem(java.lang.Object entityOrId)
Returns true if the given entity exists in the container.
|
protected void |
detachListener(java.util.Collection<E> entities) |
protected void |
fireCollectionChanged(CollectionChangeType type,
java.util.Collection<? extends E> changes) |
E |
getItem(java.lang.Object entityId)
Returns entity by its id.
|
int |
getItemIndex(java.lang.Object entityOrId)
Returns the index in the items list of the given entity or -1 if there is no such entity.
|
E |
getItemOrNull(java.lang.Object entityId)
Returns entity by its id or null if the container doesn't have an entity with the given id.
|
java.util.List<E> |
getItems()
Returns immutable list of contained entities.
|
java.util.List<E> |
getMutableItems()
Returns mutable list of contained entities.
|
Sorter |
getSorter()
Returns sorter object currently set for the container.
|
void |
itemPropertyChanged(io.jmix.core.entity.EntityPropertyChangeEvent e) |
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 |
setItem(E item)
Sets the given entity instance to the container.
|
void |
setItems(java.util.Collection<E> entities)
Sets a collection of entities to the container.
|
void |
setSorter(Sorter sorter)
Sets sorter object.
|
java.lang.String |
toString() |
void |
unmute(CollectionContainer.UnmuteEventsMode mode)
Enables all event listeners.
|
addItemChangeListener, addItemPropertyChangeListener, attachListener, detachListener, fireItemChanged, getEntityMetaClass, getFetchPlan, getItem, getItemOrNull, getLoader, mute, setFetchPlan, setLoader, unmuteclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddItemChangeListener, addItemPropertyChangeListener, getEntityMetaClass, getFetchPlan, getItem, getItemOrNull, getView, mute, setFetchPlan, setView, unmute@Autowired protected io.jmix.core.MetadataTools metadataTools
protected java.util.List<E> collection
protected java.util.Map<IndexKey,java.lang.Integer> idMap
protected Sorter sorter
public CollectionContainerImpl(io.jmix.core.metamodel.model.MetaClass metaClass)
public void setItem(@Nullable
E item)
InstanceContainersetItem in interface InstanceContainer<E>setItem in class InstanceContainerImpl<E>public java.util.List<E> getItems()
CollectionContainergetItems in interface CollectionContainer<E>public java.util.List<E> getMutableItems()
CollectionContainerCollectionContainer.CollectionChangeEvent.getMutableItems in interface CollectionContainer<E>public void setItems(@Nullable
java.util.Collection<E> entities)
CollectionContainersetItems in interface CollectionContainer<E>public E getItem(java.lang.Object entityId)
CollectionContainergetItem in interface CollectionContainer<E>@Nullable public E getItemOrNull(java.lang.Object entityId)
CollectionContainergetItemOrNull in interface CollectionContainer<E>public int getItemIndex(java.lang.Object entityOrId)
CollectionContainergetItemIndex in interface CollectionContainer<E>entityOrId - entity instance or its idpublic boolean containsItem(java.lang.Object entityOrId)
CollectionContainercontainsItem in interface CollectionContainer<E>entityOrId - entity instance or its idpublic void replaceItem(E entity)
CollectionContainer
Sends CollectionContainer.CollectionChangeEvent of the SET_ITEM or ADD_ITEMS type.
replaceItem in interface CollectionContainer<E>protected void replaceInCollection(int idx,
E entity)
protected void addToCollection(E entity)
public io.jmix.core.common.event.Subscription addCollectionChangeListener(java.util.function.Consumer<CollectionContainer.CollectionChangeEvent<E>> listener)
CollectionContainerCollectionContainer.CollectionChangeEvent.addCollectionChangeListener in interface CollectionContainer<E>@Nullable public Sorter getSorter()
CollectionContainergetSorter in interface CollectionContainer<E>public void setSorter(Sorter sorter)
CollectionContainersetSorter in interface CollectionContainer<E>public void unmute(CollectionContainer.UnmuteEventsMode mode)
CollectionContainermode.unmute in interface CollectionContainer<E>mode - modepublic void itemPropertyChanged(io.jmix.core.entity.EntityPropertyChangeEvent e)
itemPropertyChanged in interface ItemPropertyChangeNotifieritemPropertyChanged in class InstanceContainerImpl<E>protected void fireCollectionChanged(CollectionChangeType type, java.util.Collection<? extends E> changes)
protected void attachListener(java.util.Collection<E> entities)
protected void detachListener(java.util.Collection<E> entities)
protected void buildIdMap()
protected void clearItemIfNotExists()
public java.lang.String toString()
toString in class InstanceContainerImpl<E>