Interface ChainedNode
- All Superinterfaces:
BlanknessRequestable, OptionalHeaderHolder
- All Known Implementing Classes:
ImmutableChainedNode
A
ChainedNode has the following attributes. -0 or 1 header -an
arbitrary number of child ChainedNodes -0 or 1 next
ChainedNode
A ChainedNode that does not have a header, does not contain
attributes and does not have a next ChainedNode is blank.
A ChainedNode is not mutable.- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionbooleangetChildNodeAtOneBasedIndex(int oneBasedIndex) intExtendedIterable<? extends ChainedNode> getFirstChildNodeWithHeader(String header) doubleintbooleandoubletoDouble()inttoInt()Node<?> toNode()Methods inherited from interface BlanknessRequestable
isBlankMethods inherited from interface OptionalHeaderHolder
getHeader, getHeaderOrEmptyString, getOptionalHeader, hasHeader, hasHeader
-
Method Details
-
containsChildNodes
boolean containsChildNodes()- Returns:
- true if the current
ChainedNodecontains child nodes, false otherwise
-
getChildNodeAtOneBasedIndex
- Parameters:
oneBasedIndex-- Returns:
- the child node of the current
ChainedNodeat the given oneBasedIndex - Throws:
RuntimeException- if the currentChainedNodedoes not contain a child node at the given oneBasedIndex.
-
getChildNodeCount
int getChildNodeCount()- Returns:
- the number of child nodes of the current
ChainedNode.
-
getChildNodes
ExtendedIterable<? extends ChainedNode> getChildNodes()- Returns:
- the child nodes of the current
ChainedNode.
-
getFirstChildNodeWithHeader
- Parameters:
header-- Returns:
- the first child node with the given header from the current
ChainedNode - Throws:
RuntimeException- if the currentChainedNodedoes not contain a child node with the given header.
-
getNextNode
ChainedNode getNextNode()- Returns:
- the next node of the current
ChainedNode - Throws:
RuntimeException- if the currentChainedNodedoes not have a next node.
-
getSingleChildNode
ChainedNode getSingleChildNode()- Returns:
- the single child node of the current
ChainedNode - Throws:
RuntimeException- if the currentChainedNodedoes not contain a child node or contains multiple child nodes.
-
getSingleChildNodeHeader
String getSingleChildNodeHeader()- Returns:
- the header of the single child node of the current
ChainedNode - Throws:
RuntimeException- if the currentChainedNodedoes not contain a child node or contains multiple child nodesRuntimeException- if the single child node of the currentChainedNodedoes not have a header.
-
getSingleChildNodeAsDouble
double getSingleChildNodeAsDouble()- Returns:
- a double representation of the single child node of the current
ChainedNode - Throws:
RuntimeException- if the currentChainedNodedoes not contain a child nodes or contains multiple child nodesRuntimeException- if the single child node of the currentChainedNodedoes not have a headerRuntimeException- if the header of the single child node of the currentChainedNodedoes not represent a double.
-
getSingleChildNodeAsInt
int getSingleChildNodeAsInt()- Returns:
- a int representation of the single child node of the current
ChainedNode - Throws:
RuntimeException- if the currentChainedNodedoes not contain a child node or contains multiple child nodesRuntimeException- if the single child node of the currentChainedNodedoes not have a headerRuntimeException- if the header of the single child node of the currentChainedNodedoes not represent an int.
-
getSingleChildNodeAsString
String getSingleChildNodeAsString()- Returns:
- a
Stringrepresentation of the single child node of the currentChainedNode - Throws:
RuntimeException- if the currentChainedNodedoes not contain a child node or contains multiple child nodes.
-
hasNextNode
boolean hasNextNode()- Returns:
- true if the current
ChainedNodehas a next node, false otherwise
-
toDouble
double toDouble()- Returns:
- the double the current
ChainedNoderepresents - Throws:
RuntimeException- if the currentChainedNodedoes not represent a double.
-
toInt
int toInt()- Returns:
- the int the current
ChainedNoderepresents - Throws:
RuntimeException- if the currentChainedNodedoes not represent an int.
-
toNode
Node<?> toNode()AChainedNoderepresents aNodeif: -TheChainedNodedoes not have a next node. -Each child nodes of theChainedNoderepresents aNode.- Returns:
- a
Noderepresentation of the currentChainedNode - Throws:
RuntimeException- if the currentChainedNodedoes not represent aNode.
-