Class TraversableNodeTree<E>

java.lang.Object
org.fulib.fx.data.TraversableNodeTree<E>
Type Parameters:
E - The type of the values stored in the tree.
All Implemented Interfaces:
TraversableTree<E>

public class TraversableNodeTree<E> extends Object implements TraversableTree<E>
A tree that can be traversed by a path in form of directory-like structure implemented using nodes.
  • Constructor Details

    • TraversableNodeTree

      public TraversableNodeTree()
      Creates a new traversable tree.
  • Method Details

    • root

      @Nullable public E root()
      Description copied from interface: TraversableTree
      Returns the value of the root node.
      Specified by:
      root in interface TraversableTree<E>
      Returns:
      The value of the root node.
    • traverse

      public E traverse(String path)
      Description copied from interface: TraversableTree
      Traverses the tree to the given path. The current node will be set to the node at the given path.
      Specified by:
      traverse in interface TraversableTree<E>
      Parameters:
      path - The path to traverse to.
      Returns:
      The value at the given path, or null if the path does not exist.
    • get

      @Nullable public E get(String path)
      Description copied from interface: TraversableTree
      Returns the value of the tree at the given path.
      Specified by:
      get in interface TraversableTree<E>
      Parameters:
      path - The path to traverse to.
      Returns:
      The value at the given path, or null if the path does not exist.
    • containsPath

      public boolean containsPath(String path)
      Description copied from interface: TraversableTree
      Checks if there is a node at the given path.
      Specified by:
      containsPath in interface TraversableTree<E>
    • current

      @Nullable public E current()
      Description copied from interface: TraversableTree
      Returns the value of the currently visited node.
      Specified by:
      current in interface TraversableTree<E>
      Returns:
      The value of the current node.
    • insert

      public void insert(@NotNull @NotNull String path, @NotNull E value)
      Inserts a value at the given path. If the path does not exist, it will be created.

      If the path starts with a slash, the root node will be used as the starting point.

      If the path does not start with a slash, the current node will be used as the starting point.

      Specified by:
      insert in interface TraversableTree<E>
      Parameters:
      path - The path to insert the value at.
      value - The value to insert.
    • currentNode

      public TraversableNodeTree.Node<E> currentNode()
    • setCurrentNode

      public void setCurrentNode(TraversableNodeTree.Node<E> node)