Module is.codion.common.model
Package is.codion.common.model.filter
Interface FilterModel.IncludedItems<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 interfaceProvides a way to respond to changes to the included items -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int index, Collection<T> items) Adds the given items at the given index and sorts the included items if sorting is enabled.booleanAdds the given item at the given index and sorts the included items if sorting is enabled.added()booleanReturns true if the given item is includedget()get(int index) intremove(int index) Removes from this model the included element at the given indexremove(int fromIndex, int toIndex) Removes from this model all included elements whose index is betweenfromIndex, inclusive andtoIndex, exclusivebooleanSets the item at the given index.intsize()voidsort()Sorts the included items using thisFilterModel.Sortinstance, preserving the selection.Methods inherited from interface is.codion.common.observer.Observable
addConsumer, addListener, addWeakConsumer, addWeakListener, getOrThrow, getOrThrow, is, isNot, isNull, isNullable, observer, optional, removeConsumer, removeListener, removeWeakConsumer, removeWeakListener
-
Method Details
-
get
- Specified by:
getin interfaceObservable<T>- Returns:
- the included items or an empty list if all items are filtered
-
predicate
FilterModel.IncludedPredicate<T> predicate()- Returns:
- the
FilterModel.IncludedPredicatecontrolling which items should be included
-
added
Observer<Collection<T>> added()- Returns:
- an
Observernotified when items have been added
-
selection
SingleSelection<T> selection()- Returns:
- the
SingleSelectioninstance for these items
-
contains
Returns true if the given item is included- Parameters:
item- the item- Returns:
- true if the item is included
-
indexOf
- Parameters:
item- the item- Returns:
- the index of the item in this model, -1 if it is not included
-
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 included 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 included items
- Throws:
IndexOutOfBoundsException- in case the index is out of bounds
-
add
Adds the given items at the given index and sorts the included 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 included 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 included 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 included 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
-
size
int size()- Returns:
- the number of included items
-
sort
void sort()Sorts the included items using thisFilterModel.Sortinstance, preserving the selection.- See Also:
-