Interface Node<N extends Node<N>>

Type Parameters:
N - the type of a Node
All Superinterfaces:
BlanknessRequestable, FormattedStringRepresentable, OptionalHeaderHolder
All Known Subinterfaces:
IMutableNode<N>
All Known Implementing Classes:
AbstractMutableNode, AbstractNode, FileNode, ImmutableNode, MutableNode

public interface Node<N extends Node<N>> extends BlanknessRequestable, FormattedStringRepresentable, OptionalHeaderHolder
A Node can have a header and contain an arbitrary number of child Nodes. A Node that does not have a header and does not contain any child Node is blank.
Author:
Silvan Wyss
  • Method Details

    • containsChildNode

      boolean containsChildNode(Predicate<Node<?>> selector)
      Parameters:
      selector -
      Returns:
      true if the current Node contains a child Node the given selector selects, false otherwise
    • containsChildNodes

      boolean containsChildNodes()
      Returns:
      true if the current Node contains child Nodes, false otherwise
    • containsChildNodeWithHeader

      boolean containsChildNodeWithHeader(String header)
      Parameters:
      header -
      Returns:
      true if the current Node contains a child Node with the given header, false otherwise
    • getChildNodeCount

      int getChildNodeCount()
      Returns:
      the number of child Nodes of the current Node
    • getChildNodeCount

      int getChildNodeCount(Predicate<Node<?>> selector)
      Parameters:
      selector -
      Returns:
      the number of child Nodes the given selector selects from the current Node
      Throws:
      RuntimeException - if the given selector is null
    • getChildNodesHeaders

      ExtendedIterable<String> getChildNodesHeaders()
      Returns:
      the headers of the child Nodes of the current Node
      Throws:
      RuntimeException - if one of the child Nodes of the current Node does not have a header
    • getOptionalStoredFirstChildNode

      Optional<N> getOptionalStoredFirstChildNode(Predicate<Node<?>> selector)
      Parameters:
      selector -
      Returns:
      a new Optional with the first child Node the given selector selects from the current Node, an empty Optional otherwise
      Throws:
      RuntimeException - if the given selector is null
    • getStoredChildNodeAtOneBasedIndex

      N getStoredChildNodeAtOneBasedIndex(int oneBasedIndex)
      Parameters:
      oneBasedIndex -
      Returns:
      the child Node at the given oneBasedIndex from the current Node
      Throws:
      RuntimeException - if the current Node does not contain a child Node at the given oneBasedIndex
    • getStoredChildNodes

      ExtendedIterable<N> getStoredChildNodes()
      Returns:
      the child Nodes of the current Node
    • getStoredChildNodes

      ExtendedIterable<N> getStoredChildNodes(Predicate<Node<?>> selector)
      Parameters:
      selector -
      Returns:
      the child Nodes the given selector selects from the current Node
      Throws:
      RuntimeException - if the given selector is null
    • getStoredChildNodesWithHeader

      ExtendedIterable<N> getStoredChildNodesWithHeader(String header)
      Parameters:
      header -
      Returns:
      the child Nodes with the given header from the current Node
    • getStoredFirstChildNode

      N getStoredFirstChildNode()
      Returns:
      the first child Node from the current Node
      Throws:
      RuntimeException - if the current Node does not contain a child Node
    • getStoredFirstChildNode

      N getStoredFirstChildNode(Predicate<Node<?>> selector)
      Parameters:
      selector -
      Returns:
      the first child Node the given selector selects from the current Node
      Throws:
      RuntimeException - if the given selector is null
      RuntimeException - if the current Node does not contain a child Node the given selector selects
    • getStoredFirstChildNodeWithHeader

      N getStoredFirstChildNodeWithHeader(String header)
      Parameters:
      header -
      Returns:
      the first child Node with the given header from the current Node
      Throws:
      RuntimeException - if the current Node does not contain a child Node with the given header
    • getStoredSingleChildNode

      N getStoredSingleChildNode()
      Returns:
      the single child Node of the current Node
      Throws:
      RuntimeException - if the current Node does not contain child Nodes or contains several child Nodes
    • getSingleChildNodeAsBoolean

      boolean getSingleChildNodeAsBoolean()
      Returns:
      the boolean the single child Node of the current Node represents
      Throws:
      RuntimeException - if the current Node does not contain child Nodes or contains several child Nodes
      RuntimeException - if the single child Node of the current Node does not represent a boolean
    • getSingleChildNodeAsDouble

      double getSingleChildNodeAsDouble()
      Returns:
      the double the single child Node of the current Node represents
      Throws:
      RuntimeException - if the current Node does not contain child Nodes or contains several child Nodes
      RuntimeException - if the single child Node of the current Node does not represent a double
    • getSingleChildNodeAsInt

      int getSingleChildNodeAsInt()
      Returns:
      the int the single child Node of the current Node represents
      Throws:
      RuntimeException - if the current Node does not contain child Nodes or contains several child Nodes
      RuntimeException - if the single child Node of the current Node does not represent an int
    • getSingleChildNodeHeader

      String getSingleChildNodeHeader()
      Returns:
      the header of the single child Node of the current Node
      Throws:
      RuntimeException - if the current Node does not contain child Nodes or contains several child Nodes
      RuntimeException - if the single child Node of the current Node does not have a header
    • toBoolean

      boolean toBoolean()
      Returns:
      the boolean the current Node represents
      Throws:
      RuntimeException - if the current Node does not represent a boolean
    • toDouble

      double toDouble()
      Returns:
      the double the current Node represents
      Throws:
      RuntimeException - if the current Node does not represent a double
    • toInt

      int toInt()
      Returns:
      the int the current Node represents
      Throws:
      RuntimeException - if the current Node does not represent an int
    • toXml

      IXmlNode<?> toXml()
      Returns:
      a IXmlNode representation of the current Node
    • withNewHeader

      Node<?> withNewHeader(String header)
      Parameters:
      header -
      Returns:
      a new Node from the current Node with the given new header
      Throws:
      RuntimeException - if the given header is null or blank