com.vaadin.signals.impl.
Class TreeRevision
Direct Known Subclasses:
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 Summary
ConstructorsConstructorDescriptionTreeRevision
(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.
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Asserts that the nodes in this revision are internally consistent.
Get the data node for the given node id, if present.
nodes()
Gets the nodes that make up this revision.
Gets a map of signal commands for creating any nodes owned by this tree.
ownerId()
Gets the id of the tree that this revision belongs to.
-
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, notnull
nodes
- the map of state nodes in this revision, notnull
originalInserts
- the map of insert commands that created any nodes owned by this tree, notnull
-
-
Method Details
-
ownerId
Gets the id of the tree that this revision belongs to.
Returns:
the owner id, not
null
See Also:
-
nodes
Gets the nodes that make up this revision.
Returns:
a map from node id to node, not
null
-
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
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, notnull
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
assert
keyword. While the return type isboolean
, it will never returnfalse
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
-