Class Node

All Implemented Interfaces:
IOptionalHeaderHolder, INode<Node>, BlanknessRequestable

public final class Node extends AbstractNode<Node>
A Node is not mutable.
Author:
Silvan Wyss
  • Field Details

    • EMPTY_NODE

      public static final Node EMPTY_NODE
  • Method Details

    • fromEnum

      public static Node fromEnum(Enum<?> paramEnum)
      Parameters:
      paramEnum -
      Returns:
      a new Node from the given paramEnum. throws RuntimeException if the given paramEnum is null.
    • fromFile

      public static Node fromFile(String filePath)
      Parameters:
      filePath -
      Returns:
      a new Node from the file with the given filePath.
      Throws:
      RuntimeException - if the given filePath is not valid.
      RuntimeException - if the file with the given filePath does not represent a Node.
    • fromNode

      public static Node fromNode(INode<?> node)
      Parameters:
      node -
      Returns:
      a new Node from the given INode.
      Throws:
      RuntimeException - if the given node is null.
    • fromString

      public static Node fromString(String string)
      Parameters:
      string -
      Returns:
      a new Node from the given string.
      Throws:
      RuntimeException - if the given string does not represent a Node.
    • withChildNode

      public static Node withChildNode(boolean childNode)
      Parameters:
      childNode -
      Returns:
      a new Node with the given childNode.
    • withChildNode

      public static Node withChildNode(double childNode)
      Parameters:
      childNode -
      Returns:
      a new Node with the given childNode.
    • withChildNode

      public static Node withChildNode(INode<?> childNode)
      Parameters:
      childNode -
      Returns:
      a new Node with the given childNode.
      Throws:
      RuntimeException - if the given childNode is null.
    • withChildNode

      public static Node withChildNode(long childNode)
      Parameters:
      childNode -
      Returns:
      a new Node with the given childNode.
    • withChildNodes

      public static Node withChildNodes(INode<?>... childNodes)
      Parameters:
      childNodes -
      Returns:
      a new Node with the given childNodes.
      Throws:
      RuntimeException - if the given childNodes is null.
      RuntimeException - if one of the given childNodes is null.
    • withChildNodes

      public static Node withChildNodes(Iterable<? extends INode<?>> childNodes)
      Parameters:
      childNodes -
      Returns:
      a new Node with the given childNodes.
      Throws:
      RuntimeException - if the given childNodes is null.
      RuntimeException - if one of the given childNodes is null.
    • withChildNodes

      public static Node withChildNodes(String... childNodes)
      Parameters:
      childNodes -
      Returns:
      a new Node with the given childNodes.
      Throws:
      RuntimeException - if the given childNodes is null.
      RuntimeException - if one of the given childNodes does not represent a Node.
    • withHeader

      public static Node withHeader(boolean header)
      Parameters:
      header -
      Returns:
      a new Node with the given header.
    • withHeader

      public static Node withHeader(double header)
      Parameters:
      header -
      Returns:
      a new Node with the given header.
    • withHeader

      public static Node withHeader(long header)
      Parameters:
      header -
      Returns:
      a new Node with the given header.
    • withHeader

      public static Node withHeader(String header)
      Parameters:
      header -
      Returns:
      a new Node with the given header.
      Throws:
      RuntimeException - if the given header is null or blank.
    • withHeaderAndChildNode

      public static Node withHeaderAndChildNode(String header, boolean childNode)
      Parameters:
      header -
      childNode -
      Returns:
      a new Node with the given childNode.
      Throws:
      RuntimeException - if the given header is null or blank.
    • withHeaderAndChildNode

      public static Node withHeaderAndChildNode(String header, double childNode)
      Parameters:
      header -
      childNode -
      Returns:
      a new Node with the given childNode. throws RuntimeException if the given header is null or blank.
    • withHeaderAndChildNode

      public static Node withHeaderAndChildNode(String header, INode<?> childNode)
      Parameters:
      header -
      childNode -
      Returns:
      a new Node with the given header and childNode.
      Throws:
      RuntimeException - if the given header is null or blank.
      RuntimeException - if the given childNode is null.
    • withHeaderAndChildNode

      public static Node withHeaderAndChildNode(String header, long childNode)
      Parameters:
      header -
      childNode -
      Returns:
      a new Node with the given childNode. throws RuntimeException if the given header is null or blank.
    • withHeaderAndChildNode

      public static Node withHeaderAndChildNode(String header, String childNode)
      Parameters:
      header -
      childNode -
      Returns:
      a new Node with the given header and childNode.
      Throws:
      RuntimeException - if the given header is null or blank.
      RuntimeException - if the given childNode does not represent a Node.
    • withHeaderAndChildNodes

      public static Node withHeaderAndChildNodes(String header, INode<?>... childNodes)
      Parameters:
      header -
      childNodes -
      Returns:
      a new Node with the given header and childNodes.
      Throws:
      RuntimeException - if the given header is null or blank.
      RuntimeException - if the given childNodes is null.
      RuntimeException - if one of the given childNodes is null.
    • withHeaderAndChildNodes

      public static Node withHeaderAndChildNodes(String header, Iterable<? extends INode<?>> childNodes)
      Parameters:
      header -
      childNodes -
      Returns:
      a new Node with the given header and childNodes.
      Throws:
      RuntimeException - if the given header is null or blank.
      RuntimeException - if the given childNodes is null.
      RuntimeException - if one of the given childNodes is null.
    • withHeaderAndChildNodes

      public static Node withHeaderAndChildNodes(String header, String... childNodes)
      Parameters:
      header -
      childNodes -
      Returns:
      a new Node with the given header and childNodes.
      Throws:
      RuntimeException - if the given header is null or blank.
      RuntimeException - if the given childNodes is null.
      RuntimeException - if one of the given childNodes does not represent a Node.
    • getHeader

      public String getHeader()
      Returns:
      the header of the current IOptionalHeaderHolder.
    • getStoredChildNodes

      public IContainer<Node> getStoredChildNodes()
      Returns:
      the child INodes of the current INode.
    • hasHeader

      public boolean hasHeader()
      Returns:
      true if the current IOptionalHeaderHolder has a header, false otherwise.
    • withNewHeader

      public INode<?> withNewHeader(String header)
      Parameters:
      header -
      Returns:
      a new INode from the current INode with the given new header.