Interface SelectionModel<C extends Component,​T>

  • Type Parameters:
    T - the type of the items to select
    C - the component type
    All Superinterfaces:
    Serializable
    All Known Subinterfaces:
    SelectionModel.Multi<C,​T>, SelectionModel.Single<C,​T>

    public interface SelectionModel<C extends Component,​T>
    extends Serializable
    Models the selection logic of a Listing component. Determines how items can be selected and deselected.
    Since:
    1.0.
    Author:
    Vaadin Ltd
    • Method Detail

      • getSelectedItems

        Set<T> getSelectedItems()
        Returns an immutable set of the currently selected items. It is safe to invoke other SelectionModel methods while iterating over the set.

        Implementation note: the iteration order of the items in the returned set should be well-defined and documented by the implementing class.

        Returns:
        the items in the current selection, not null
      • select

        void select​(T item)
        Selects the given item. Depending on the implementation, may cause other items to be deselected. If the item is already selected, does nothing.
        Parameters:
        item - the item to select, not null
      • deselect

        void deselect​(T item)
        Deselects the given item. If the item is not currently selected, does nothing.
        Parameters:
        item - the item to deselect, not null
      • deselectAll

        void deselectAll()
        Deselects all currently selected items, if any.
      • isSelected

        default boolean isSelected​(T item)
        Returns whether the given item is currently selected.
        Parameters:
        item - the item to check, not null
        Returns:
        true if the item is selected, false otherwise
      • addSelectionListener

        Registration addSelectionListener​(SelectionListener<C,​T> listener)
        Adds a generic listener to this selection model, accepting both single and multiselection events.
        Parameters:
        listener - the listener to add, not null
        Returns:
        a registration handle for removing the listener