Class ImmutableChainedNode
java.lang.Object
ch.nolix.base.document.chainednode.ImmutableChainedNode
- All Implemented Interfaces:
OptionalHeaderHolder, ChainedNode, BlanknessRequestable
A
ImmutableChainedNode has the following attributes. -0 or 1 header
-an arbitrary number of child ImmutableChainedNodes -0 or 1 next
ImmutableChainedNode
A ImmutableChainedNode is not mutable.- Author:
- Silvan Wyss
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanstatic ImmutableChainedNodefromChainedNode(ChainedNode chainedNode) static ImmutableChainedNodestatic ImmutableChainedNodefromString(String string) getChildNodeAtOneBasedIndex(int index) intstatic StringgetEscapeStringForString(String string) getFirstChildNodeWithHeader(String header) doubleintstatic StringgetStoredginStringFromEscapeString(String escapeString) inthashCode()booleanbooleanbooleanisBlank()doubletoDouble()inttoInt()toNode()toString()static ImmutableChainedNodewithChildNodes(Node<?>... nodes) static ImmutableChainedNodewithChildNodesFromNodes(Iterable<? extends Node<?>> attributes) Creates a newImmutableChainedNodewith the given attributes.static ImmutableChainedNodewithHeader(String header) static ImmutableChainedNodewithHeaderAndChildNode(String header, ChainedNode childNode) static ImmutableChainedNodewithHeaderAndChildNode(String header, Node<?> childNode) static ImmutableChainedNodewithHeaderAndChildNodes(String header, ChainedNode... childNodes) static ImmutableChainedNodewithHeaderAndChildNodes(String header, Node<?>... childNodes) static ImmutableChainedNodewithHeaderAndChildNodes(String header, Iterable<? extends ChainedNode> attributes) static ImmutableChainedNodewithHeaderAndChildNodesFromNodes(String header, Iterable<? extends Node<?>> attributes) Creates a newImmutableChainedNodewith the given header and attributes.static ImmutableChainedNodewithHeaderAndNextNode(String header, ImmutableChainedNode nextNode) Methods inherited from interface OptionalHeaderHolder
getHeaderOrEmptyString, getOptionalHeader, hasHeader
-
Field Details
-
EMPTY_CHAINED_NODE
-
DOT_CODE
- See Also:
-
COMMA_CODE
- See Also:
-
DOLLAR_SYMBOL_CODE
- See Also:
-
OPEN_BRACKET_CODE
- See Also:
-
CLOSED_BRACKET_CODE
- See Also:
-
-
Method Details
-
fromChainedNode
- Parameters:
chainedNode-- Returns:
- a
ImmutableChainedNodefrom the given chainedNode - Throws:
RuntimeException- if the given chainedNode is null
-
fromNode
- Parameters:
node-- Returns:
- a new
ImmutableChainedNodefrom the given node.
-
fromString
- Parameters:
string-- Returns:
- a new
ImmutableChainedNodethe given string represents - Throws:
RuntimeException- if the given string does not represent aImmutableChainedNode.
-
getEscapeStringForString
-
getStoredginStringFromEscapeString
-
withChildNodes
- Parameters:
nodes-- Returns:
- a new
ImmutableChainedNodewith the childNodes - Throws:
RuntimeException- if the given nodes is nullRuntimeException- if one of the given nodes is null
-
withChildNodesFromNodes
Creates a newImmutableChainedNodewith the given attributes.- Parameters:
attributes-- Returns:
- a new
ImmutableChainedNodewith the given attributes - Throws:
RuntimeException- if one of the given attributes is null
-
withHeader
- Parameters:
header-- Returns:
- a new
ImmutableChainedNodewith the given header - Throws:
RuntimeException- if the given header is nullRuntimeException- if the given header is blank
-
withHeaderAndChildNode
- Parameters:
header-childNode-- Returns:
- a new
ImmutableChainedNodewith the given header and childNode - Throws:
RuntimeException- if the given header is null or blankRuntimeException- if the given childNode is null
-
withHeaderAndChildNodes
public static ImmutableChainedNode withHeaderAndChildNodes(String header, ChainedNode... childNodes) - Parameters:
header-childNodes-- Returns:
- a new
ImmutableChainedNodewith the given header and childNodes - Throws:
RuntimeException- if the given header is null or blankRuntimeException- if the given header is blankRuntimeException- if the given childNodes is nullRuntimeException- if one of the given childNodes is null
-
withHeaderAndChildNode
- Parameters:
header-childNode-- Returns:
- a new
ImmutableChainedNodewith the given header and childNode - Throws:
RuntimeException- if the given header is null or blankRuntimeException- if the given header is blank
-
withHeaderAndChildNodes
public static ImmutableChainedNode withHeaderAndChildNodes(String header, Iterable<? extends ChainedNode> attributes) - Parameters:
header-attributes-- Returns:
- a new
ImmutableChainedNodewith the given header and attributes - Throws:
RuntimeException- if the given header is nullRuntimeException- if the given header is blankRuntimeException- if one of the given attribute is null
-
withHeaderAndChildNodes
- Parameters:
header-childNodes-- Returns:
- a new
ImmutableChainedNodewith the given header and childNodes - Throws:
RuntimeException- if the given header is null or blankRuntimeException- if the given childNodes is nullRuntimeException- if one of the given childNodes is null
-
withHeaderAndChildNodesFromNodes
public static ImmutableChainedNode withHeaderAndChildNodesFromNodes(String header, Iterable<? extends Node<?>> attributes) Creates a newImmutableChainedNodewith the given header and attributes.- Parameters:
header-attributes-- Returns:
- a new
ImmutableChainedNodewith the given header and attributes - Throws:
RuntimeException- if the given header is nullRuntimeException- if the given header is blankRuntimeException- if one of the given attributes is null
-
withHeaderAndNextNode
public static ImmutableChainedNode withHeaderAndNextNode(String header, ImmutableChainedNode nextNode) - Parameters:
header-nextNode-- Returns:
- a new
ImmutableChainedNodewith the given header and nextNode - Throws:
RuntimeException- if the given header is nullRuntimeException- if the given header is blankRuntimeException- if the given nextNode is null
-
containsChildNodes
public boolean containsChildNodes()- Specified by:
containsChildNodesin interfaceChainedNode- Returns:
- true if the current
ChainedNodecontains child nodes, false otherwise
-
equals
-
getChildNodeCount
public int getChildNodeCount()- Specified by:
getChildNodeCountin interfaceChainedNode- Returns:
- the number of attributes of the current
ImmutableChainedNode.
-
getChildNodeAtOneBasedIndex
- Specified by:
getChildNodeAtOneBasedIndexin interfaceChainedNode- Parameters:
index-- Returns:
- the attribute at the given index of the current
ImmutableChainedNode - Throws:
RuntimeException- if the given index is not positiveArgumentDoesNotHaveAttributeException- if the currentImmutableChainedNodedoes not contain an attribute at the given index.
-
getChildNodes
- Specified by:
getChildNodesin interfaceChainedNode- Returns:
- the attributes of the current
ImmutableChainedNode.
-
getFirstChildNodeWithHeader
- Specified by:
getFirstChildNodeWithHeaderin interfaceChainedNode- Parameters:
header-- Returns:
- the first attribute with the given header from the current
ImmutableChainedNode - Throws:
ArgumentDoesNotHaveAttributeException- if the currentImmutableChainedNodedoes not contain an attribute with the given header.
-
getHeader
- Specified by:
getHeaderin interfaceOptionalHeaderHolder- Returns:
- the header of the current
ImmutableChainedNode - Throws:
ArgumentDoesNotHaveAttributeException- if the currentImmutableChainedNodedoes not have a header.
-
getNextNode
- Specified by:
getNextNodein interfaceChainedNode- Returns:
- the next node of the current
ImmutableChainedNode - Throws:
ArgumentDoesNotHaveAttributeException- if the currentImmutableChainedNodedoes not have a next node.
-
getSingleChildNode
- Specified by:
getSingleChildNodein interfaceChainedNode- Returns:
- the one attribute of the current
ImmutableChainedNode - Throws:
RuntimeException- if the currentImmutableChainedNodedoes not contain an attributeRuntimeException- if the currentImmutableChainedNodecontains several attributes.
-
getSingleChildNodeHeader
- Specified by:
getSingleChildNodeHeaderin interfaceChainedNode- Returns:
- the header of the single child node of the current
ChainedNode
-
getSingleChildNodeAsDouble
public double getSingleChildNodeAsDouble()- Specified by:
getSingleChildNodeAsDoublein interfaceChainedNode- Returns:
- a double representation of the single child node of the current
ChainedNode
-
getSingleChildNodeAsInt
public int getSingleChildNodeAsInt()- Specified by:
getSingleChildNodeAsIntin interfaceChainedNode- Returns:
- a int representation of the single child node of the current
ChainedNode
-
getSingleChildNodeAsString
- Specified by:
getSingleChildNodeAsStringin interfaceChainedNode- Returns:
- a
Stringrepresentation of the single child node of the currentChainedNode
-
hashCode
-
hasHeader
public boolean hasHeader()- Specified by:
hasHeaderin interfaceOptionalHeaderHolder- Returns:
- true if the current
OptionalHeaderHolderhas a header, false otherwise
-
hasNextNode
public boolean hasNextNode()- Specified by:
hasNextNodein interfaceChainedNode- Returns:
- true if the current
ChainedNodehas a next node, false otherwise
-
isBlank
public boolean isBlank()- Specified by:
isBlankin interfaceBlanknessRequestable- Returns:
- true if
BlanknessRequestableis blank, false otherwise
-
toDouble
public double toDouble()- Specified by:
toDoublein interfaceChainedNode- Returns:
- the double the current
ChainedNoderepresents
-
toInt
public int toInt()- Specified by:
toIntin interfaceChainedNode- Returns:
- the int the current
ChainedNoderepresents
-
toNode
AChainedNoderepresents aNodeif: -TheChainedNodedoes not have a next node. -Each child nodes of theChainedNoderepresents aNode.- Specified by:
toNodein interfaceChainedNode- Returns:
- a
Noderepresentation of the currentChainedNode
-
toString
-