com.vaadin.flow.data.selection.
Interface SelectionModel<C extends Component,T>
-
Type Parameters:
T
- the type of the items to selectC
- the component typeAll Superinterfaces:
All Known Subinterfaces:
GridMultiSelectionModel<T>
,GridSelectionModel<T>
,GridSingleSelectionModel<T>
,SelectionModel.Multi<C,T>
,SelectionModel.Single<C,T>
All Known Implementing Classes:
AbstractGridMultiSelectionModel
,AbstractGridSingleSelectionModel
,GridNoneSelectionModel
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
SelectionModel.Multi<C extends Component,T>
A selection model in which multiple items can be selected at the same time.
static interface
SelectionModel.Single<C extends Component,T>
A selection model in which at most one item can be selected at a time.
-
Method Summary
All Methods Modifier and Type Method Description Registration
addSelectionListener(SelectionListener<C,T> listener)
Adds a generic listener to this selection model, accepting both single and multiselection events.
void
deselect(T item)
Deselects the given item.
void
deselectAll()
Deselects all currently selected items, if any.
Optional<T>
getFirstSelectedItem()
Get first selected data item.
Set<T>
getSelectedItems()
Returns an immutable set of the currently selected items.
default boolean
isSelected(T item)
Returns whether the given item is currently selected.
void
select(T item)
Selects the given item.
-
-
-
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
-
getFirstSelectedItem
Optional<T> getFirstSelectedItem()
Get first selected data item.
This is the same as
SelectionModel.Single.getSelectedItem()
in case of single selection and the first selected item fromgetSelectedItems()
in case of multiselection.Returns:
the first selected item.
-
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 nullReturns:
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, notnull
Returns:
a registration handle for removing the listener
-
-