Package com.storedobject.vaadin
Class DataList<T>
java.lang.Object
com.storedobject.vaadin.DataList<T>
- Type Parameters:
T- Type of data in the list.
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>,SequencedCollection<T>
A list data structure with a "refresh" listener. The refresh methods of the
listeners (
DataList.RefreshListener) are called whenever list is changed by adding/deleting/updating items.
This class may be used instead of normal List if you want to use it as data for
ListGrid. The same instance may be used in multiple ListGrids and all grids will be
simultaneously updated when data is updated programmatically.
- Author:
- Syam
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDefinition of refresh listener that can be added to theDataList. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends T> collection) booleanaddAll(Collection<? extends T> collection) com.vaadin.flow.shared.RegistrationaddRefreshListener(DataList.RefreshListener<T> listener) Add a refresh listener for this list.voidclear()booleanbooleancontainsAll(Collection<?> collection) get(int index) getData()Get the data of this list.intbooleanisEmpty()iterator()intlastIndexOf(Object item) listIterator(int index) voidrefresh()Inform the listeners that the items in this list are refreshed due to addition or deletion of items.voidInform the listeners that an item of this in this list is refreshed.remove(int index) booleanbooleanremoveAll(Collection<?> collection) booleanvoidreplaceAll(UnaryOperator<T> operator) booleanretainAll(Collection<?> collection) intsize()voidsort(Comparator<? super T> comparator) subList(int fromIndex, int toIndex) Object[]toArray()<T1> T1[]toArray(T1[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, reversed, spliterator
-
Constructor Details
-
DataList
public DataList()Constructor. -
DataList
-
-
Method Details
-
getData
Get the data of this list. If the data is directly manipulated,refresh()orrefresh(Object)should be invoked to inform the listeners about the changes.- Returns:
- Data of this list.
-
size
-
isEmpty
-
contains
-
iterator
-
toArray
-
toArray
-
add
-
remove
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceList<T>
-
addAll
-
addAll
-
removeAll
-
removeIf
- Specified by:
removeIfin interfaceCollection<T>
-
retainAll
-
clear
-
get
-
set
-
add
-
remove
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
subList
-
refresh
public void refresh()Inform the listeners that the items in this list are refreshed due to addition or deletion of items. -
refresh
Inform the listeners that an item of this in this list is refreshed.- Parameters:
item- Item that is changed.
-
addRefreshListener
Add a refresh listener for this list.- Parameters:
listener- Listener to add.- Returns:
- Registration.
-
sort
-
replaceAll
- Specified by:
replaceAllin interfaceList<T>
-