Class NodeList<T extends Serializable>
java.lang.Object
com.vaadin.flow.internal.nodefeature.NodeFeature
com.vaadin.flow.internal.nodefeature.NodeList<T>
- Type Parameters:
T- the type of the items in the list
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SerializableNodeList,StateNodeNodeList
A state node feature that structures data as a list.
Should not be used directly, use one of the extending classes instead, which
provide a type safe API while ensuring the list is Serializable.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidInserts an item at the given index of the list.protected voidAdds an item to the end of the list.protected voidaddAll(Collection<? extends T> items) Adds all provided items to the end of the list.protected voidclear()Removes all nodes, including those not known by the server.voidcollectChanges(Consumer<NodeChange> collector) Collects all changes that are recorded for this feature.voidforEachChild(Consumer<StateNode> action) Passes each child node instance to the given consumer.voidGenerates all changes that would be needed to take this node from its initial empty state to its current state.protected Tget(int index) Gets the item at the given index.protected List<AbstractListChange<T>> Gets or creates the list used to track changes that should be sent to the client.protected intGets the position of a value in the list.protected booleanChecks whether this list contains node values.iterator()Gets an iterator returning all items in this list.voidonDetach()Called when the state node has been detached from the state tree.protected Tremove(int index) Removes the item at the given index.protected intsize()Gets the number of items in this list.Methods inherited from class com.vaadin.flow.internal.nodefeature.NodeFeature
allowsChanges, attachPotentialChild, detatchPotentialChild, getNode, onAttach
-
Constructor Details
-
NodeList
Creates a new list for the given node.- Parameters:
node- the node that the list belongs to
-
-
Method Details
-
size
protected int size()Gets the number of items in this list.- Returns:
- the number of items
-
get
Gets the item at the given index.- Parameters:
index- the of the desired item- Returns:
- the item at the given index
-
add
Adds an item to the end of the list.- Parameters:
item- the item to add
-
addAll
Adds all provided items to the end of the list.- Parameters:
items- a collection of items to add, not null
-
add
Inserts an item at the given index of the list.- Parameters:
index- index to insert atitem- the item to insert
-
remove
Removes the item at the given index.- Parameters:
index- index of the item to remove- Returns:
- the element previously at the specified position
-
getChangeTracker
Gets or creates the list used to track changes that should be sent to the client.This method is non-private for testing purposes.
- Returns:
- the list to track changes in
-
collectChanges
Description copied from class:NodeFeatureCollects all changes that are recorded for this feature.- Specified by:
collectChangesin classNodeFeature- Parameters:
collector- a consumer accepting node changes
-
forEachChild
Description copied from class:NodeFeaturePasses each child node instance to the given consumer.- Specified by:
forEachChildin classNodeFeature- Parameters:
action- the consumer that accepts each child
-
generateChangesFromEmpty
public void generateChangesFromEmpty()Description copied from class:NodeFeatureGenerates all changes that would be needed to take this node from its initial empty state to its current state.- Specified by:
generateChangesFromEmptyin classNodeFeature
-
isNodeValues
protected boolean isNodeValues()Checks whether this list contains node values.- Returns:
trueif this list contains node values;falseif this list contains primitive values
-
clear
protected void clear()Removes all nodes, including those not known by the server. -
indexOf
Gets the position of a value in the list.- Parameters:
value- the value to look for- Returns:
- the position in the list or -1 if not found
-
iterator
Gets an iterator returning all items in this list.- Returns:
- an iterator returning all items
-
onDetach
public void onDetach()Description copied from class:NodeFeatureCalled when the state node has been detached from the state tree.- Overrides:
onDetachin classNodeFeature
-