Interface SelectionModel.Single<C extends com.vaadin.flow.component.Component,T>

Type Parameters:
C - the component type
T - the type of the items to select
All Superinterfaces:
SelectionModel<C,T>, Serializable
Enclosing interface:
SelectionModel<C extends com.vaadin.flow.component.Component,T>

public static interface SelectionModel.Single<C extends com.vaadin.flow.component.Component,T> extends SelectionModel<C,T>
A selection model in which at most one item can be selected at a time. Selecting another item deselects the originally selected item.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.vaadin.flow.data.selection.SelectionModel

    SelectionModel.Multi<C extends com.vaadin.flow.component.Component,T>, SelectionModel.Single<C extends com.vaadin.flow.component.Component,T>
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Deselects all currently selected items, if any.
    default Optional<T>
    Get first selected data item.
    Returns the currently selected item, or an empty optional if no item is selected.
    default Set<T>
    Returns a singleton set of the currently selected item or an empty set if no item is selected.
    boolean
    Gets whether it's allowed to deselect the selected row through the UI.
    void
    select(T item)
    Selects the given item.
    void
    setDeselectAllowed(boolean deselectAllowed)
    Sets whether it's allowed to deselect the selected row through the UI.
    default void
    Sets the current selection to the given item, or clears selection if given null.

    Methods inherited from interface com.vaadin.flow.data.selection.SelectionModel

    addSelectionListener, deselect, isSelected
  • Method Details

    • select

      void select(T item)
      Selects the given item. If another item was already selected, that item is deselected.
      Specified by:
      select in interface SelectionModel<C extends com.vaadin.flow.component.Component,T>
      Parameters:
      item - the item to select
    • getSelectedItem

      Optional<T> getSelectedItem()
      Returns the currently selected item, or an empty optional if no item is selected.
      Returns:
      an optional of the selected item if any, an empty optional otherwise
    • setSelectedItem

      default void setSelectedItem(T item)
      Sets the current selection to the given item, or clears selection if given null.
      Parameters:
      item - the item to select or null to clear selection
    • deselectAll

      default void deselectAll()
      Description copied from interface: SelectionModel
      Deselects all currently selected items, if any.
      Specified by:
      deselectAll in interface SelectionModel<C extends com.vaadin.flow.component.Component,T>
    • getSelectedItems

      default Set<T> getSelectedItems()
      Returns a singleton set of the currently selected item or an empty set if no item is selected.
      Specified by:
      getSelectedItems in interface SelectionModel<C extends com.vaadin.flow.component.Component,T>
      Returns:
      a singleton set of the selected item if any, an empty set otherwise
      See Also:
    • getFirstSelectedItem

      default Optional<T> getFirstSelectedItem()
      Description copied from interface: SelectionModel
      Get first selected data item.

      This is the same as getSelectedItem() in case of single selection and the first selected item from SelectionModel.getSelectedItems() in case of multiselection.

      Specified by:
      getFirstSelectedItem in interface SelectionModel<C extends com.vaadin.flow.component.Component,T>
      Returns:
      the first selected item.
    • setDeselectAllowed

      void setDeselectAllowed(boolean deselectAllowed)
      Sets whether it's allowed to deselect the selected row through the UI. Deselection is allowed by default.
      Parameters:
      deselectAllowed - true if the selected row can be deselected without selecting another row instead; otherwise false.
    • isDeselectAllowed

      boolean isDeselectAllowed()
      Gets whether it's allowed to deselect the selected row through the UI.
      Returns:
      true if deselection is allowed; otherwise false