Interface MultiSelection.Items<R>

Type Parameters:
R - the item type
All Superinterfaces:
Observable<List<R>>, Observer<List<R>>, Value<List<R>>
Enclosing interface:
MultiSelection<T>

public static interface MultiSelection.Items<R> extends Value<List<R>>

Manages the selected items.

An item may be equal to several of the items, at different indexes. Each item given to set(Collection), add(Collection) or restore(Collection) selects an index of its own, in order of preference:

  1. an index holding the same instance
  2. an index holding an equal item
an already selected one first in either case when setting or adding, keeping the selection in place, otherwise the first one. remove(Object) and contains(Object) cover every selected index holding an equal item, and get() holds the item at each selected index, so that set(get()) and add(get()) leave the selection as is.
  • Method Details

    • get

      List<R> get()
      Specified by:
      get in interface Observable<R>
      Returns:
      the value
    • set

      void set(Collection<R> items)
      Parameters:
      items - the items to select
    • set

      void set(Predicate<R> predicate)
      Sets the items passing the predicate test as the selection
      Parameters:
      predicate - the predicate
    • restore

      void restore(Collection<R> items)

      Selects the given items without notifying MultiSelection.changing(), the ones not found among the indexed items left out.

      For a model restoring the selection after its items changed: the selected items having moved, been replaced or removed, the selection follows along, rather than being changed by request, which is what MultiSelection.changing() is for.

      The current selection is not consulted, a view may have shifted or cleared it while the items changed. An item selects the index holding the same instance, which sorting and filtering keep, otherwise the first one holding an equal item, so an item replaced by an equal one, as by a refresh, or removed while an equal one remains, selects the first equal one not selected along with it.

      Parameters:
      items - the items to select
      See Also:
    • add

      void add(Predicate<R> predicate)
      Adds the items passing the predicate test to the selection
      Parameters:
      predicate - the predicate
    • add

      void add(R item)
      Adds the given item to the selection
      Parameters:
      item - the item to add to the selection
    • add

      void add(Collection<R> items)
      Adds the given items to the selection
      Parameters:
      items - the items to add to the selection
    • remove

      void remove(R item)
      Removes the given item from the selection, at every selected index holding an equal item
      Parameters:
      item - the item to remove from the selection
    • remove

      void remove(Collection<R> items)
      Removes the given items from the selection, at every selected index holding an equal item
      Parameters:
      items - the items to remove from the selection
    • contains

      boolean contains(R item)
      Parameters:
      item - the item
      Returns:
      true if an item equal to the given one is selected, at any index