Class NodeState
java.lang.Object
com.yahoo.documentapi.messagebus.systemstate.rule.NodeState
- Author:
- Simon Thoresen Hult
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a child to this node at the given location.clear()
Clears both the internal state and child list, then compacts the tree from this node upwards.Copies the state content of another node state object into this.Returns the child at the given location relative to this.Returns the child at the given location relative to this.Returns the map of child nodes for iteration.Retrieves some arbitrary state information for a given key.removeChild
(String key) Removes the named child node from this node, and attempts to compact the system state from this node upwards by removing empty nodes.removeState
(String key) Removes the named (key, value) state pair from this node, and attempts to compact the system state from this node upwards by removing empty nodes.Sets the parent of this node.Sets some arbitrary state data in this node.toString()
-
Field Details
-
NODE_PARENT
A location string that expresses the use of the PARENT node.- See Also:
-
NODE_CURRENT
A location string that expresses the use of THIS node.- See Also:
-
-
Constructor Details
-
NodeState
public NodeState()Creates a node state that no internal content. -
NodeState
Creates a node state based on a list of argument objects. These arguments are iterated and added to this node's internal state map.- Parameters:
args
- The arguments to use as state.
-
-
Method Details
-
addChild
Adds a child to this node at the given location. The key can be a location string, in which case the necessary intermediate node states are created.- Parameters:
key
- The location at which to add the child.child
- The child node to add.- Returns:
- This, to allow chaining.
-
getChild
Returns the child at the given location relative to this.- Parameters:
key
- The location of the child to return.- Returns:
- The child object, null if not found.
-
getChild
Returns the child at the given location relative to this. This method can be forced to return a child node even if it does not exist, by adding all intermediate nodes and the target node itself.- Parameters:
key
- The location of the child to return.force
- Whether or not to force a return value by creating missing nodes.- Returns:
- The child object, null if not found.
-
getChildren
Returns the map of child nodes for iteration.- Returns:
- The internal child map.
-
removeChild
Removes the named child node from this node, and attempts to compact the system state from this node upwards by removing empty nodes.- Parameters:
key
- The child to remove.- Returns:
- The result of invoking
compact()
after the remove.
-
getState
Retrieves some arbitrary state information for a given key. The key can be a location string, in which case the necessary intermediate nodes are traversed. If the key is not found, this method returns null.- Parameters:
key
- The name of the state information to return.- Returns:
- The value of the state key.
-
setState
Sets some arbitrary state data in this node. The key can be a location string, in which case the necessary intermediate nodes are traversed and even created if missing.- Parameters:
key
- The key to set.value
- The value to assign to the key.- Returns:
- This, to allow chaining.
-
removeState
Removes the named (key, value) state pair from this node, and attempts to compact the system state from this node upwards by removing empty nodes.- Parameters:
key
- The state variable to clear.- Returns:
- The result of invoking
compact()
after the remove.
-
copy
Copies the state content of another node state object into this.- Parameters:
node
- The node state to copy into this.- Returns:
- This, to allow chaining.
-
clear
Clears both the internal state and child list, then compacts the tree from this node upwards.- Returns:
- The result of invoking
compact()
after the remove.
-
setParent
Sets the parent of this node.- Parameters:
parent
- The parent node.id
- The identifier of this node as seen in the parent.- Returns:
- This, to allow chaining.
-
toString
-