Package com.usatiuk.kleppmanntree
Interface TreeNode<TimestampT extends Comparable<TimestampT>,PeerIdT extends Comparable<PeerIdT>,MetaT extends NodeMeta,NodeIdT>
- Type Parameters:
TimestampT
- the type of the timestampPeerIdT
- the type of the peer IDMetaT
- the type of the node metadataNodeIdT
- the type of the node ID
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
JKleppmannTreeNode
public interface TreeNode<TimestampT extends Comparable<TimestampT>,PeerIdT extends Comparable<PeerIdT>,MetaT extends NodeMeta,NodeIdT>
extends Serializable
Represents a node in the Kleppmann tree.
-
Method Summary
Modifier and TypeMethodDescriptionchildren()
Get the children of this node.key()
Get the ID of the node.Get the last effective operation that moved this node.meta()
Get the metadata stored in this node.default String
name()
Get the name of the node.parent()
Get the ID of the parent node.withChildren
(org.pcollections.PMap<String, NodeIdT> children) Make a copy of this node with new children.withLastEffectiveOp
(OpMove<TimestampT, PeerIdT, MetaT, NodeIdT> lastEffectiveOp) Make a copy of this node with a new last effective operation.Make a copy of this node with new metadata.withParent
(NodeIdT parent) Make a copy of this node with a new parent.
-
Method Details
-
key
NodeIdT key()Get the ID of the node.- Returns:
- the ID of the node
-
parent
NodeIdT parent()Get the ID of the parent node.- Returns:
- the ID of the parent node
-
lastEffectiveOp
OpMove<TimestampT,PeerIdT, lastEffectiveOp()MetaT, NodeIdT> Get the last effective operation that moved this node.- Returns:
- the last effective operation
-
meta
Get the metadata stored in this node.- Returns:
- the metadata of the node
-
name
Get the name of the node. If the node has metadata, the name is extracted from it, otherwise the key is converted to string.- Returns:
- the name of the node
-
children
Get the children of this node.- Returns:
- a map of child IDs to their respective nodes
-
withParent
Make a copy of this node with a new parent.- Parameters:
parent
- the ID of the new parent node- Returns:
- a new TreeNode instance with the updated parent
-
withLastEffectiveOp
TreeNode<TimestampT,PeerIdT, withLastEffectiveOpMetaT, NodeIdT> (OpMove<TimestampT, PeerIdT, MetaT, NodeIdT> lastEffectiveOp) Make a copy of this node with a new last effective operation.- Parameters:
lastEffectiveOp
- the new last effective operation- Returns:
- a new TreeNode instance with the updated last effective operation
-
withMeta
Make a copy of this node with new metadata.- Parameters:
meta
- the new metadata- Returns:
- a new TreeNode instance with the updated metadata
-
withChildren
TreeNode<TimestampT,PeerIdT, withChildrenMetaT, NodeIdT> (org.pcollections.PMap<String, NodeIdT> children) Make a copy of this node with new children.- Parameters:
children
- the new children- Returns:
- a new TreeNode instance with the updated children
-