Interface CollectionContainer<E>

All Superinterfaces:
InstanceContainer<E>
All Known Subinterfaces:
CollectionPropertyContainer<E>, KeyValueCollectionContainer
All Known Implementing Classes:
CollectionContainerImpl, CollectionPropertyContainerImpl, KeyValueCollectionContainerImpl

public interface CollectionContainer<E> extends InstanceContainer<E>
Container that holds a collection of entity instances.
  • Method Details

    • getItems

      List<E> getItems()
      Returns immutable list of contained entities.
    • setItems

      void setItems(@Nullable Collection<E> entities)
      Sets a collection of entities to the container.
    • getMutableItems

      List<E> getMutableItems()
      Returns mutable list of contained entities. Changes in the list produce CollectionContainer.CollectionChangeEvent.
    • getItem

      E getItem(Object entityId)
      Returns entity by its id.
      Throws:
      IllegalArgumentException - if the container doesn't have an entity with the given id
    • getItemOrNull

      @Nullable E getItemOrNull(Object entityId)
      Returns entity by its id or null if the container doesn't have an entity with the given id.
    • getItemIndex

      int getItemIndex(Object entityOrId)
      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

      boolean containsItem(Object entityOrId)
      Returns true if the given entity exists in the container.
      Parameters:
      entityOrId - entity instance or its id
    • replaceItem

      void replaceItem(E entity)
      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 the SET_ITEM or ADD_ITEMS type.

    • getSorter

      @Nullable Sorter getSorter()
      Returns sorter object currently set for the container.
    • setSorter

      void setSorter(Sorter sorter)
      Sets sorter object.
    • unmute

      Enables all event listeners. Events fired on this call depend on the passed mode.
      Parameters:
      mode - mode
    • addCollectionChangeListener

      Subscription addCollectionChangeListener(Consumer<CollectionContainer.CollectionChangeEvent<E>> listener)