Class ListAddChange<T extends Serializable>

  • Type Parameters:
    T - the type of the items in the node list
    All Implemented Interfaces:
    Serializable

    public class ListAddChange<T extends Serializable>
    extends AbstractListChange<T>
    Change describing an add operation in a list node feature.

    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

      • ListAddChange

        public ListAddChange​(NodeList<T> list,
                             boolean nodeValues,
                             int index,
                             List<? extends T> newItems)
        Creates a new list add change.
        Parameters:
        list - the changed list
        nodeValues - true if the values are StateNodes, false otherwise
        index - the index of the add operations
        newItems - a list of new items
    • Method Detail

      • getNewItems

        public List<? extends T> getNewItems()
        Gets the added items.
        Returns:
        the added items
      • isEmpty

        public boolean isEmpty()
        Returns whether this add operation still contains any new items.
        Returns:
        true if no new items, false if still has new items
      • copy

        public ListAddChange<T> copy​(List<? extends T> items)
        Gets a copy of the change with the same data except a list of new items.
        Parameters:
        items - new list of items
        Returns:
        a copy of the change based on new items
      • populateJson

        protected void populateJson​(elemental.json.JsonObject json,
                                    ConstantPool constantPool)
        Description copied from class: NodeChange
        Overridden by subclasses to populate a JSON object when serializing.
        Overrides:
        populateJson in class NodeFeatureChange
        Parameters:
        json - the json object to populate
        constantPool - the constant pool to use for serializing constant pool references
      • removeItem

        public void removeItem​(T item)
        Removes item from the change list.

        Note: This should be used only when list of changes is being re-indexed after adding a new change.

        Parameters:
        item - Item to be removed.