Interface INode<N extends INode<N>>

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

public interface INode<N extends INode<N>> extends BlanknessRequestable, FormattedStringRepresentable, OptionalHeaderHolder
A INode has the following attributes. -0 or 1 header -an arbitrary number of child INodes A INode that does not have a header and does not contains attributes is blank. A sub type of INode may be or may be not mutable.
Author:
Silvan Wyss
  • Method Details

    • containsChildNodes

      boolean containsChildNodes()
      Returns:
      true if the current INode contains child INodes, false otherwise
    • containsChildNodeThat

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

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

      boolean containsOneChildNode()
      Returns:
      true if the current INode contains 1 child INode, false otherwise
    • getChildNodeCount

      int getChildNodeCount()
      Returns:
      the number of child INodes of the current INode
    • getChildNodeCount

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

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

      Optional<N> getOptionalStoredFirstChildNodeThat(Predicate<INode<?>> selector)
      Parameters:
      selector -
      Returns:
      a new Optional with the first child INode the given selector selects from the current INode, an empty Optional otherwise
    • getStoredChildNodeAtOneBasedIndex

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

      ExtendedIterable<N> getStoredChildNodes()
      Returns:
      the child INodes of the current INode
    • getStoredChildNodesThat

      ExtendedIterable<N> getStoredChildNodesThat(Predicate<INode<?>> selector)
      Parameters:
      selector -
      Returns:
      the child INodes the given selector selects from the current INode
    • getStoredChildNodesWithHeader

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

      N getStoredFirstChildNode()
      Returns:
      the first child INode from the current INode
      Throws:
      RuntimeException - if the current INode does not contain child INodes
    • getStoredFirstChildNodeThat

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

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

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

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

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

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

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

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

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

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

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

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