Module is.codion.common.model
Package is.codion.common.model.filter
Interface FilterModel.VisibleItems<T>
- Type Parameters:
T
- the item type
- All Superinterfaces:
Observable<List<T>>
,Observer<List<T>>
- Enclosing interface:
FilterModel<T>
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Provides a way to respond to changes to the visible items -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(int index, Collection<T> items) Adds the given items at the given index and sorts the visible items if sorting is enabled.boolean
Adds the given item at the given index and sorts the visible items if sorting is enabled.added()
boolean
Returns true if the given item is visibleint
count()
get()
get
(int index) int
remove
(int index) Removes from this model the visible element at the given indexremove
(int fromIndex, int toIndex) Removes from this model all visible elements whose index is betweenfromIndex
, inclusive andtoIndex
, exclusiveboolean
Sets the item at the given index.void
sort()
Sorts the visible items using thisFilterModel.Sort
instance, preserving the selection.Methods inherited from interface is.codion.common.observable.Observable
addConsumer, addListener, addWeakConsumer, addWeakListener, getOrThrow, getOrThrow, isEqualTo, isNotEqualTo, isNull, isNullable, observer, optional, removeConsumer, removeListener, removeWeakConsumer, removeWeakListener
-
Method Details
-
get
- Specified by:
get
in interfaceObservable<T>
- Returns:
- the visible items or an empty list if no item is visible
-
predicate
FilterModel.VisiblePredicate<T> predicate()- Returns:
- the
FilterModel.VisiblePredicate
controlling which items should be visible
-
added
Observer<Collection<T>> added()- Returns:
- an
Observer
notified when items have been added
-
selection
SingleSelection<T> selection()- Returns:
- the
SingleSelection
instance for these items
-
contains
Returns true if the given item is visible- Parameters:
item
- the item- Returns:
- true if the item is visible
-
indexOf
- Parameters:
item
- the item- Returns:
- the index of the item in this model, -1 if it is not visible
-
get
- Parameters:
index
- the row index- Returns:
- the item at the given index in this model
- Throws:
IndexOutOfBoundsException
- in case the index is out of bounds
-
add
Adds the given item at the given index and sorts the visible items if sorting is enabled.
Note that if the item does not pass the
predicate()
it is filtered right away and the method returns false.- Parameters:
index
- the indexitem
- the item to add- Returns:
- true if the item was added to the visible items
- Throws:
IndexOutOfBoundsException
- in case the index is out of bounds
-
add
Adds the given items at the given index and sorts the visible items if sorting is enabled.
Note that if an item does not pass the
predicate()
it is filtered right away.- Parameters:
index
- the index at which to add the itemsitems
- the items to add- Returns:
- true if one or more of the items was added to the visible items
- Throws:
IndexOutOfBoundsException
- in case the index is out of bounds
-
set
Sets the item at the given index. Note that sorting is NOT performed after the item has been set.
Note that if the item does not pass the
predicate()
this method has no effect.- Parameters:
index
- the indexitem
- the item- Returns:
- true if the item was set, false if it did not pass the
predicate()
- Throws:
IndexOutOfBoundsException
- in case the index is out of bounds- See Also:
-
remove
Removes from this model the visible element at the given index
- Parameters:
index
- the index of the row to be removed- Returns:
- the removed item
- Throws:
IndexOutOfBoundsException
- in case the index is out of bounds
-
remove
Removes from this model all visible elements whose index is between
fromIndex
, inclusive andtoIndex
, exclusive- Parameters:
fromIndex
- index of first row to be removedtoIndex
- index after last row to be removed- Returns:
- the removed items
- Throws:
IndexOutOfBoundsException
- in case the indexes are out of bounds
-
count
int count()- Returns:
- the number of visible items
-
sort
void sort()Sorts the visible items using thisFilterModel.Sort
instance, preserving the selection.- See Also:
-