Class NodeList<T extends Serializable>

  • Type Parameters:
    T - the type of the items in the list
    All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    SerializableNodeList, StateNodeNodeList

    public abstract class NodeList<T extends Serializable>
    extends NodeFeature
    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:
    Serialized Form
    • Constructor Detail

      • NodeList

        protected NodeList​(StateNode node)
        Creates a new list for the given node.
        Parameters:
        node - the node that the list belongs to
    • Method Detail

      • size

        protected int size()
        Gets the number of items in this list.
        Returns:
        the number of items
      • get

        protected T get​(int index)
        Gets the item at the given index.
        Parameters:
        index - the of the desired item
        Returns:
        the item at the given index
      • add

        protected void add​(T item)
        Adds an item to the end of the list.
        Parameters:
        item - the item to add
      • addAll

        protected void addAll​(Collection<? extends T> items)
        Adds all provided items to the end of the list.
        Parameters:
        items - a collection of items to add, not null
      • add

        protected void add​(int index,
                           T item)
        Inserts an item at the given index of the list.
        Parameters:
        index - index to insert at
        item - the item to insert
      • remove

        protected T remove​(int index)
        Removes the item at the given index.
        Parameters:
        index - index of the item to remove
        Returns:
        the element previously at the specified position
      • getChangeTracker

        protected List<AbstractListChange<T>> 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

        public void collectChanges​(Consumer<NodeChange> collector)
        Description copied from class: NodeFeature
        Collects all changes that are recorded for this feature.
        Specified by:
        collectChanges in class NodeFeature
        Parameters:
        collector - a consumer accepting node changes
      • forEachChild

        public void forEachChild​(Consumer<StateNode> action)
        Description copied from class: NodeFeature
        Passes each child node instance to the given consumer.
        Specified by:
        forEachChild in class NodeFeature
        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 class NodeFeature
      • 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

        protected int indexOf​(T value)
        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

        protected Iterator<T> 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 class NodeFeature