Interface NodeNavigator

All Superinterfaces:
Iterable<Node>
All Known Implementing Classes:
Config, EntryNode, InvalidNode, Node, SectionNode, SimpleNode, VoidNode

public interface NodeNavigator extends Iterable<Node>
Something that contains or references nodes and can be navigated. Not all navigation options are universally-supported.

All nodes are node navigators, even if they are EntryNodes that do not support children. Entry nodes will return null for all child-based operations (as if the requested node was simply not present).
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Node
    get(String key)
    Obtains the immediate child node at this (direct) key.
    @NotNull Node
    Obtains the current node represented by this navigator.
    default @Nullable Node
    getNodeAt(@NotNull String @NotNull ... steps)
    Fetches a node at position inside the current node.
    default @Nullable Node
    getNodeAt(@Nullable String path)
    Fetches a node at a path inside the current node.
    default @Nullable String
    Gets the raw value from the node at the given path.
    default Iterator<Node>
    If this navigator represents a node with no children (e.g.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • iterator

      default Iterator<Node> iterator()
      If this navigator represents a node with no children (e.g. an entry node) this iterator will be empty.
      Specified by:
      iterator in interface Iterable<Node>
      Returns:
      An iterator for all children represented by this node navigator
    • get

      @Nullable @Nullable Node get(String key)
      Obtains the immediate child node at this (direct) key. If this does not represent a node that can have children (e.g. an EntryNode) then it must return null.
      Parameters:
      key - The name of the node
      Returns:
      The child node if one is present, otherwise null
    • getCurrentNode

      @NotNull @NotNull Node getCurrentNode()
      Obtains the current node represented by this navigator. If this navigator is itself a node, it should return itself.
      Returns:
      The main node represented by this navigator
    • getNodeAt

      @Nullable default @Nullable Node getNodeAt(@NotNull @NotNull String @NotNull ... steps)
      Fetches a node at position inside the current node. If any stage represents a node with no children (e.g. an entry node) the result will be null.

      In the following example, the two entry nodes can be obtained from the root with "first", "one" and "first", "two", "three" (respectively).
      
       first:
       	one: value
       	two:
       		three: value
       
      Parameters:
      steps - The node steps to traverse
      Returns:
      The node at the final step (or nothing)
    • getNodeAt

      @Contract("null -> this") @Nullable default @Nullable Node getNodeAt(@Nullable @Nullable String path)
      Fetches a node at a path inside the current node. If any stage represents a node with no children (e.g. an entry node) the result will be null.

      In the following example, the two entry nodes can be obtained from the root with "first.one" and "first.two.three" (respectively).
      
       first:
       	one: value
       	two:
       		three: value
       


      If the path is null or empty, this node will be returned.
      Parameters:
      path - The path to the node, separated by .
      Returns:
      The node at the path (or nothing)
      See Also:
    • getValue

      @Nullable default @Nullable String getValue(String path)
      Gets the raw value from the node at the given path. If any part of the path is invalid, this will return null.
      Parameters:
      path - The node path from which to get the value
      Returns:
      If such a node exists, its value, otherwise null