Interface Node<T extends NodeInfo>

All Superinterfaces:
NodeInfo
All Known Implementing Classes:
JpaNode

public interface Node<T extends NodeInfo> extends NodeInfo
A node in a nested set tree.
  • Method Details

    • moveAsLastChildOf

      void moveAsLastChildOf(Node<T> dest)
      Moves this node in the tree, positioning it as the last child of the given node.
      Parameters:
      dest -
    • moveAsFirstChildOf

      void moveAsFirstChildOf(Node<T> dest)
      Moves this node in the tree, positioning it as the first child of the given node.
      Parameters:
      dest -
    • moveAsNextSiblingOf

      void moveAsNextSiblingOf(Node<T> dest)
      Moves this node in the tree, positioning it as the successive sibling of the given node.
      Parameters:
      dest -
    • moveAsPrevSiblingOf

      void moveAsPrevSiblingOf(Node<T> dest)
      Moves this node as the previous sibling of the given node.
      Parameters:
      dest -
    • getChildren

      List<Node<T>> getChildren()
      Gets the children children of the node (direct descendants).
      Returns:
      The children of the node.
    • getDescendants

      List<Node<T>> getDescendants(int depth)
      Gets descendants of this node, up to a certain depth.
      Parameters:
      depth -
      Returns:
      The descendants of the node, up to the specified depth.
    • getDescendants

      List<Node<T>> getDescendants()
      Gets the descendants of this node.
      Returns:
      The descendants of this node.
    • getAncestors

      List<Node<T>> getAncestors()
      Gets all ancestors of this node.
      Returns:
      The ancestors of the node.
    • addChild

      Node<T> addChild(T child)
      Adds a node as the last child of this node.
      Parameters:
      child - The child to add.
      Returns:
      The newly inserted child node.
    • getParent

      Node<T> getParent()
      Gets the parent node of this node.
      Returns:
      The parent node or NULL if there is no parent node.
    • getFirstChild

      Node<T> getFirstChild()
      Gets the first child node of this node.
      Returns:
      The first child node of this node.
    • getLastChild

      Node<T> getLastChild()
      Gets the last child node of this node.
      Returns:
      The last child node.
    • unwrap

      T unwrap()
      Unwraps the node, returning the wrapped object.
      Returns:
      The wrapped object.
    • delete

      void delete()
      Deletes the node and all its descendants from the tree.
    • isRoot

      boolean isRoot()
      Tests if this node is a root node.
      Returns:
      TRUE if this node is a root node, FALSE otherwise.
    • hasParent

      boolean hasParent()
      Tests if the node has a parent. If it does not have a parent, it is a root node.
      Returns:
      TRUE if this node has a parent node, FALSE otherwise.
    • hasChildren

      boolean hasChildren()
      Tests if the node has any children.
      Returns:
      TRUE if the node has children, FALSE otherwise.
    • isValid

      boolean isValid()
      Tests whether the node is a valid node. A valid node is a node with a valid position in the tree, represented by its left, right and level values.
      Returns:
      TRUE if the node is valid, FALSE otherwise.
    • isDescendantOf

      boolean isDescendantOf(Node<T> other)
      Determines if this node is a descendant of the given node.
      Returns:
      TRUE if this node is a descendant of the given node, FALSE otherwise.