com.vaadin.flow.internal.nodefeature.
Class NodeList<T extends Serializable>
Type Parameters:
T
- the type of the items in the list
All Implemented Interfaces:
Direct Known Subclasses:
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 void
Inserts an item at the given index of the list.
protected void
Adds an item to the end of the list.
protected void
addAll
(Collection<? extends T> items) Adds all provided items to the end of the list.
protected void
clear()
Removes all nodes, including those not known by the server.
void
collectChanges
(Consumer<NodeChange> collector) Collects all changes that are recorded for this feature.
void
forEachChild
(Consumer<StateNode> action) Passes each child node instance to the given consumer.
void
Generates all changes that would be needed to take this node from its initial empty state to its current state.
protected T
get
(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 int
Gets the position of a value in the list.
protected boolean
Checks whether this list contains node values.
iterator()
Gets an iterator returning all items in this list.
void
onDetach()
Called when the state node has been detached from the state tree.
protected T
remove
(int index) Removes the item at the given index.
protected int
size()
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 itemReturns:
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 removeReturns:
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:
NodeFeature
Collects all changes that are recorded for this feature.
Specified by:
collectChanges
in classNodeFeature
Parameters:
collector
- a consumer accepting node changes -
forEachChild
Description copied from class:
NodeFeature
Passes each child node instance to the given consumer.
Specified by:
forEachChild
in classNodeFeature
Parameters:
action
- the consumer that accepts each child -
generateChangesFromEmpty
public void generateChangesFromEmpty()Description copied from class:
NodeFeature
Generates all changes that would be needed to take this node from its initial empty state to its current state.
Specified by:
generateChangesFromEmpty
in classNodeFeature
-
isNodeValues
protected boolean isNodeValues()Checks whether this list contains node values.
Returns:
true
if this list contains node values;false
if 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 forReturns:
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:
NodeFeature
Called when the state node has been detached from the state tree.
Overrides:
onDetach
in classNodeFeature
-