public interface CollectionContainer<E extends Entity> extends InstanceContainer<E>
Modifier and Type | Interface and Description |
---|---|
static class |
CollectionContainer.CollectionChangeEvent<T extends Entity>
Event sent on changes in the container items collection - adding, removing, replacing elements.
|
static class |
CollectionContainer.UnmuteEventsMode |
InstanceContainer.ItemChangeEvent<T extends Entity>, InstanceContainer.ItemPropertyChangeEvent<T extends Entity>
Modifier and Type | Method and Description |
---|---|
Subscription |
addCollectionChangeListener(java.util.function.Consumer<CollectionContainer.CollectionChangeEvent<E>> listener)
Adds listener to
CollectionContainer.CollectionChangeEvent . |
boolean |
containsItem(java.lang.Object entityId)
Returns true if an item with the given id exists in the container.
|
E |
getItem(java.lang.Object entityId)
Returns entity by its id.
|
int |
getItemIndex(java.lang.Object entityId)
Returns the index in the items list of the entity with the given id 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 |
replaceItem(E entity)
If the item with the same id exists in the container, it is replaced with the given instance.
|
void |
setItems(java.util.Collection<E> entities)
Sets a collection of entities to the container.
|
void |
setSorter(Sorter sorter)
Sets sorter object.
|
void |
unmute(CollectionContainer.UnmuteEventsMode mode)
Enables all event listeners.
|
addItemChangeListener, addItemPropertyChangeListener, getEntityMetaClass, getItem, getItemOrNull, getView, mute, setItem, setView, unmute
java.util.List<E> getItems()
void setItems(@Nullable java.util.Collection<E> entities)
java.util.List<E> getMutableItems()
CollectionContainer.CollectionChangeEvent
.@Nonnull E getItem(java.lang.Object entityId)
java.lang.IllegalArgumentException
- if the container doesn't have an entity with the given id@Nullable E getItemOrNull(java.lang.Object entityId)
int getItemIndex(java.lang.Object entityId)
boolean containsItem(java.lang.Object entityId)
void replaceItem(E entity)
Sends CollectionContainer.CollectionChangeEvent
of the SET_ITEM
or ADD_ITEMS
type.
Sorter getSorter()
void setSorter(Sorter sorter)
void unmute(CollectionContainer.UnmuteEventsMode mode)
mode
.mode
- modeSubscription addCollectionChangeListener(java.util.function.Consumer<CollectionContainer.CollectionChangeEvent<E>> listener)
CollectionContainer.CollectionChangeEvent
.