com.vaadin.signals.impl.

Class TreeRevision

java.lang.Object
com.vaadin.signals.impl.TreeRevision

Direct Known Subclasses:

MutableTreeRevision, Snapshot

public abstract class TreeRevision extends Object

A revision of a signal tree. The revision keeps track of the nodes that make up the tree and any insert commands that are owned by this revision.

See Also:

  • Constructor Details

    • TreeRevision

      public TreeRevision(Id ownerId, Map<Id,Node> nodes, Map<Id,SignalCommand.ScopeOwnerCommand> originalInserts)

      Creates a new revision based on the given owner id, map of signal nodes and map of original inserts.

      Parameters:

      ownerId - the id of the tree owner, not null

      nodes - the map of state nodes in this revision, not null

      originalInserts - the map of insert commands that created any nodes owned by this tree, not null

  • Method Details

    • ownerId

      public Id ownerId()

      Gets the id of the tree that this revision belongs to.

      Returns:

      the owner id, not null

      See Also:

    • nodes

      public Map<Id,Node> nodes()

      Gets the nodes that make up this revision.

      Returns:

      a map from node id to node, not null

    • originalInserts

      public Map<Id,SignalCommand.ScopeOwnerCommand> originalInserts()

      Gets a map of signal commands for creating any nodes owned by this tree. Any signal node with a matching Node.Data.scopeOwner() is considered to be owned by that tree and such nodes should be removed if the tree is disconnected. The revision keeps track of the original insert operations so that the nodes can be inserted back again in the appropriate way if the tree is connected back again.

      Returns:

      a map from node id to signal command, not null

    • data

      public Optional<Node.Data> data(Id id)

      Get the data node for the given node id, if present. If the given id corresponds to an alias node, then alias is resolved and the data node for the alias target is returned instead.

      Parameters:

      id - the id for which to get a data node, not null

      Returns:

      an optional containing the corresponding data node, or an empty optional of there is no node with the given id

    • assertValidTree

      protected boolean assertValidTree()

      Asserts that the nodes in this revision are internally consistent.

      • All nodes are attached to the root
      • All parent-child relationships are consistent in both directions
      • No node is attached in multiple places
      • All aliases target an existing data node
      • All nodes with a matching scope owner has a matching original insert
      • All original insert entries correspond to a node with a matching scope owner
      This method is intended to be invoked with the assert keyword. While the return type is boolean, it will never return false but instead throws an assertion error from the appropriate check to make it easier to pinpoint the source of any error.

      Returns:

      true if the tree is valid, otherwise an assertion error is thrown