Interface TreeNode<TimestampT extends Comparable<TimestampT>,PeerIdT extends Comparable<PeerIdT>,MetaT extends NodeMeta,NodeIdT>

Type Parameters:
TimestampT - the type of the timestamp
PeerIdT - the type of the peer ID
MetaT - the type of the node metadata
NodeIdT - 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 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,MetaT,NodeIdT> lastEffectiveOp()
      Get the last effective operation that moved this node.
      Returns:
      the last effective operation
    • meta

      @Nullable MetaT meta()
      Get the metadata stored in this node.
      Returns:
      the metadata of the node
    • name

      default String 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

      org.pcollections.PMap<String,NodeIdT> 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,MetaT,NodeIdT> withLastEffectiveOp(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,MetaT,NodeIdT> withChildren(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