T
- data typepublic abstract class AbstractListDataView<T> extends AbstractDataView<T> implements ListDataView<T,AbstractListDataView<T>>
ListDataView
subclasses.component, dataProviderSupplier, NULL_IDENTIFIER_ERROR_MESSAGE
Constructor and Description |
---|
AbstractListDataView(SerializableSupplier<? extends DataProvider<T,?>> dataProviderSupplier,
Component component,
SerializableBiConsumer<SerializablePredicate<T>,SerializableComparator<T>> filterOrSortingChangedCallback)
Creates a new instance of
AbstractListDataView subclass and
verifies the passed data provider is compatible with this data view
implementation. |
Modifier and Type | Method and Description |
---|---|
AbstractListDataView<T> |
addFilter(SerializablePredicate<T> filter)
Adds a filter to be applied to all queries.
|
AbstractListDataView<T> |
addItem(T item)
Adds an item to the data list if it is not already present.
|
AbstractListDataView<T> |
addItemAfter(T item,
T after)
Adds an item after the given target item.
|
AbstractListDataView<T> |
addItemBefore(T item,
T before)
Adds an item before the given target item.
|
AbstractListDataView<T> |
addItems(Collection<T> items)
Adds multiple items to the data list.
|
AbstractListDataView<T> |
addItemsAfter(Collection<T> items,
T after)
Adds multiple items after the given target item.
|
AbstractListDataView<T> |
addItemsBefore(Collection<T> items,
T before)
Adds multiple items before the given target item.
|
AbstractListDataView<T> |
addSortComparator(SerializableComparator<T> sortComparator)
Adds a comparator to the data default sorting.
|
<V1 extends Comparable<? super V1>> |
addSortOrder(ValueProvider<T,V1> valueProvider,
SortDirection sortDirection)
Adds a property and direction to the default sorting.
|
boolean |
contains(T item)
Check if item is present in the currently filtered data set.
|
protected ListDataProvider<T> |
getDataProvider() |
T |
getItem(int index)
Gets the item at the given index from the data available to the
component.
|
int |
getItemCount()
Get the full item count with filters if any set.
|
Stream<T> |
getItems()
Get the full data available to the component.
|
Optional<T> |
getNextItem(T item)
Gets the item after given item from the filtered and sorted data.
|
Optional<T> |
getPreviousItem(T item)
Gets the item before given item from the filtered and sorted data.
|
protected Class<?> |
getSupportedDataProviderType()
Returns supported
DataProvider type for this DataView . |
AbstractListDataView<T> |
removeFilters()
Removes all in-memory filters set or added.
|
AbstractListDataView<T> |
removeItem(T item)
Remove an item from the data list.
|
AbstractListDataView<T> |
removeItems(Collection<T> items)
Remove multiple items from the data list.
|
AbstractListDataView<T> |
removeSorting()
Removes any default sorting that has been set or added previously.
|
AbstractListDataView<T> |
setFilter(SerializablePredicate<T> filter)
Sets a filter to be applied to the data.
|
AbstractListDataView<T> |
setSortComparator(SerializableComparator<T> sortComparator)
Sets the comparator to use as the default sorting.
|
<V1 extends Comparable<? super V1>> |
setSortOrder(ValueProvider<T,V1> valueProvider,
SortDirection sortDirection)
Sets the property and direction to use as the default sorting.
|
protected void |
validateItemIndex(int itemIndex)
Validate that index is inside bounds of the data available.
|
addItemCountChangeListener, equals, getIdentifierProvider, refreshAll, refreshItem, setIdentifierProvider, verifyDataProviderType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addItemCountChangeListener, refreshAll, refreshItem, setIdentifierProvider
public AbstractListDataView(SerializableSupplier<? extends DataProvider<T,?>> dataProviderSupplier, Component component, SerializableBiConsumer<SerializablePredicate<T>,SerializableComparator<T>> filterOrSortingChangedCallback)
AbstractListDataView
subclass and
verifies the passed data provider is compatible with this data view
implementation.dataProviderSupplier
- supplier from which the DataProvider can be gottencomponent
- the component that the dataView is bound tofilterOrSortingChangedCallback
- callback, which is being invoked when the component filtering
or sorting changes, not null
public int getItemCount()
ListDataView
DataView.addItemCountChangeListener(ComponentEventListener)
method
instead to get notified when the item count has changed.getItemCount
in interface ListDataView<T,AbstractListDataView<T>>
DataView.addItemCountChangeListener(ComponentEventListener)
public T getItem(int index)
DataView
public Stream<T> getItems()
DataView
public Optional<T> getNextItem(T item)
ListDataView
Note! Item might be present in the data set, but be filtered out or be the last item so that the next item won't be available.
getNextItem
in interface ListDataView<T,AbstractListDataView<T>>
item
- item to get next forListDataView.getPreviousItem(Object)
public Optional<T> getPreviousItem(T item)
ListDataView
Note! Item might be present in the data set, but be filtered out or be the first item so that the previous item won't be available.
getPreviousItem
in interface ListDataView<T,AbstractListDataView<T>>
item
- item to get previous forListDataView.getNextItem(Object)
public AbstractListDataView<T> addFilter(SerializablePredicate<T> filter)
ListDataView
This filter is bound to the component. Thus, any other component using
the same DataProvider
object would not be affected by setting a
filter through data view of another component. A filter set by this
method won't be retained when a new DataProvider
is set to the
component.
addFilter
in interface ListDataView<T,AbstractListDataView<T>>
filter
- the filter to add, not null
ListDataView.setFilter(SerializablePredicate)
,
ListDataView.removeFilters()
public AbstractListDataView<T> removeFilters()
ListDataView
removeFilters
in interface ListDataView<T,AbstractListDataView<T>>
ListDataView.addFilter(SerializablePredicate)
,
ListDataView.setFilter(SerializablePredicate)
public AbstractListDataView<T> setFilter(SerializablePredicate<T> filter)
ListDataView
null
will clear all
filters.
This filter is bound to the component. Thus, any other component using
the same DataProvider
object would not be affected by setting a
filter through data view of another component. A filter set by this
method won't be retained when a new DataProvider
is set to the
component.
setFilter
in interface ListDataView<T,AbstractListDataView<T>>
filter
- filter to be set, or null
to clear any previously
set filtersListDataView.addFilter(SerializablePredicate)
,
ListDataView.removeFilters()
public AbstractListDataView<T> setSortComparator(SerializableComparator<T> sortComparator)
ListDataView
This comparator is bound to the component. Thus, any other component
using the same DataProvider
object would not be affected by
setting a sort comparator through data view of another component. A
sorting set by this method won't be retained when a new
DataProvider
is set to the component.
setSortComparator
in interface ListDataView<T,AbstractListDataView<T>>
sortComparator
- a comparator to use, or null
to clear any
previously set sort orderListDataView.addSortComparator(SerializableComparator)
public AbstractListDataView<T> addSortComparator(SerializableComparator<T> sortComparator)
ListDataView
This comparator is bound to the component. Thus, any other component
using the same DataProvider
object would not be affected by
setting a sort comparator through data view of another component. A
sorting set by this method won't be retained when a new
DataProvider
is set to the component.
addSortComparator
in interface ListDataView<T,AbstractListDataView<T>>
sortComparator
- a comparator to add, not null
ListDataView.setSortComparator(SerializableComparator)
public AbstractListDataView<T> removeSorting()
ListDataView
Any other component using the same DataProvider
object would not
be affected by removing default sorting through data view of another
component.
removeSorting
in interface ListDataView<T,AbstractListDataView<T>>
ListDataView.setSortComparator(SerializableComparator)
,
ListDataView.addSortComparator(SerializableComparator)
public <V1 extends Comparable<? super V1>> AbstractListDataView<T> setSortOrder(ValueProvider<T,V1> valueProvider, SortDirection sortDirection)
ListDataView
DataProvider
.
This sort order is bound to the component. Thus, any other component
using the same DataProvider
object would not be affected by
setting a sort order through data view of another component. A sort order
set by this method won't be retained when a new DataProvider
is
set to the component.
setSortOrder
in interface ListDataView<T,AbstractListDataView<T>>
V1
- the provided value typevalueProvider
- the value provider that defines the property do sort by, not
null
sortDirection
- the sort direction to use, not null
ListDataView.addSortOrder(ValueProvider, SortDirection)
public <V1 extends Comparable<? super V1>> AbstractListDataView<T> addSortOrder(ValueProvider<T,V1> valueProvider, SortDirection sortDirection)
ListDataView
This sort order is bound to the component. Thus, any other component
using the same DataProvider
object would not be affected by
setting a sort sort through data view of another component. A sorting set
by this method won't be retained when a new DataProvider
is set
to the component.
addSortOrder
in interface ListDataView<T,AbstractListDataView<T>>
V1
- the provided value typevalueProvider
- the value provider that defines the property do sort by, not
null
sortDirection
- the sort direction to use, not null
ListDataView.setSortOrder(ValueProvider, SortDirection)
public boolean contains(T item)
ListDataView
By default, equals
method implementation of the item is used for
identity check. If a custom data provider is used, then the
DataProvider.getId(Object)
method is used instead. Item's custom
identity can be set up with a
DataView.setIdentifierProvider(IdentifierProvider)
.
contains
in interface ListDataView<T,AbstractListDataView<T>>
item
- item to search fortrue
if item is found in filtered data setDataView.setIdentifierProvider(IdentifierProvider)
protected Class<?> getSupportedDataProviderType()
AbstractDataView
DataProvider
type for this DataView
.getSupportedDataProviderType
in class AbstractDataView<T>
protected ListDataProvider<T> getDataProvider()
public AbstractListDataView<T> addItem(T item)
ListDataView
The backing List
must be mutable to use this method. Immutable
data structure will throw an exception.
addItem
in interface ListDataView<T,AbstractListDataView<T>>
item
- item to addListDataView.addItemBefore(Object, Object)
,
ListDataView.addItemAfter(Object, Object)
,
ListDataView.removeItem(Object)
public AbstractListDataView<T> addItems(Collection<T> items)
ListDataView
The backing List
must be mutable to use this method. Immutable
data structure will throw an exception.
Any items that already present in the data provider are moved to the end.
addItems
in interface ListDataView<T,AbstractListDataView<T>>
items
- collection of item to addListDataView.removeItems(Collection)
,
ListDataView.addItemsBefore(Collection, Object)
,
ListDataView.addItemsAfter(Collection, Object)
public AbstractListDataView<T> addItemAfter(T item, T after)
ListDataView
The backing List
must be mutable to use this method. Immutable
data structure will throw an exception.
If the item is already present in the data provider, then it is moved.
Note! Item is added to the unfiltered and unsorted List.
addItemAfter
in interface ListDataView<T,AbstractListDataView<T>>
item
- item to addafter
- item after which to add the item atListDataView.addItem(Object)
,
ListDataView.addItemBefore(Object, Object)
public AbstractListDataView<T> addItemBefore(T item, T before)
ListDataView
The backing List
must be mutable to use this method. Immutable
data structure will throw an exception.
If the item is already present in the data provider, then it is moved.
Note! Item is added to the unfiltered and unsorted List.
addItemBefore
in interface ListDataView<T,AbstractListDataView<T>>
item
- item to addbefore
- item before which to add the item atListDataView.addItem(Object)
,
ListDataView.addItemAfter(Object, Object)
public AbstractListDataView<T> addItemsAfter(Collection<T> items, T after)
ListDataView
The backing List
must be mutable to use this method. Immutable
data structure will throw an exception. Any items that already present in
the data provider are moved.
Note! Item is added to the unfiltered and unsorted List.
addItemsAfter
in interface ListDataView<T,AbstractListDataView<T>>
items
- collection of items to addafter
- item after which to add the item atListDataView.addItems(Collection)
,
ListDataView.addItemsBefore(Collection, Object)
public AbstractListDataView<T> addItemsBefore(Collection<T> items, T before)
ListDataView
The backing List
must be mutable to use this method. Immutable
data structure will throw an exception.
Any items that already present in the data provider are moved.
Note! Item is added to the unfiltered and unsorted List.
addItemsBefore
in interface ListDataView<T,AbstractListDataView<T>>
items
- collection of items to addbefore
- item before which to add the item atListDataView.addItems(Collection)
,
ListDataView.addItemsAfter(Collection, Object)
public AbstractListDataView<T> removeItem(T item)
ListDataView
The backing List
must be mutable to use this method. Immutable
data structure will throw an exception.
removeItem
in interface ListDataView<T,AbstractListDataView<T>>
item
- item to removeListDataView.addItem(Object)
,
ListDataView.removeItems(Collection)
public AbstractListDataView<T> removeItems(Collection<T> items)
ListDataView
The backing List
must be mutable to use this method. Immutable
data structure will throw an exception.
removeItems
in interface ListDataView<T,AbstractListDataView<T>>
items
- collection of items to removeListDataView.removeItem(Object)
,
ListDataView.removeItems(Collection)
protected void validateItemIndex(int itemIndex)
itemIndex
- item index to validateCopyright © 2022. All rights reserved.