- java.lang.Object
-
- org.github.gestalt.config.node.ConfigNodeManager
-
- All Implemented Interfaces:
ConfigNodeService
public final class ConfigNodeManager extends java.lang.Object implements ConfigNodeService
Holds and manages config nodes.
-
-
Constructor Summary
Constructors Constructor Description ConfigNodeManager()Default constructor for the ConfigNodeManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GResultOf<ConfigNode>addNode(ConfigNodeContainer newNode)Add a new node, if a root already exists merge the nodes.GResultOf<ConfigNode>navigateToNextNode(java.lang.String path, java.util.List<Token> tokens, ConfigNode currentNode)From a given node navigate to the next node.GResultOf<ConfigNode>navigateToNextNode(java.lang.String path, Token token, ConfigNode currentNode)From a given node navigate to the next node.GResultOf<ConfigNode>navigateToNode(java.lang.String path, java.util.List<Token> tokens, Tags tags)navigate to a node for a path from the root.GResultOf<java.lang.Boolean>postProcess(java.util.List<PostProcessor> postProcessors)Apply a list of Post Processors on the root node.GResultOf<ConfigNode>reloadNode(ConfigNodeContainer reloadNode)Reload a node, if there are more than one node it will merge it into the config tree in the same order as the existing node.
-
-
-
Method Detail
-
addNode
public GResultOf<ConfigNode> addNode(ConfigNodeContainer newNode) throws GestaltException
Description copied from interface:ConfigNodeServiceAdd a new node, if a root already exists merge the nodes. When adding a node and merging, the new node always takes precedence.- Specified by:
addNodein interfaceConfigNodeService- Parameters:
newNode- node to be added- Returns:
- newly merged node
- Throws:
GestaltException- any exceptions
-
postProcess
public GResultOf<java.lang.Boolean> postProcess(java.util.List<PostProcessor> postProcessors) throws GestaltException
Description copied from interface:ConfigNodeServiceApply a list of Post Processors on the root node. This allows a post processor to modify the config tree in any way. It will navigate to each node in the tree and pass it to the post processor. The post processors are run in order of priority, with the next post processor getting the results from the previous. The post processor returns a node that is then used to replace the current node.- Specified by:
postProcessin interfaceConfigNodeService- Parameters:
postProcessors- list of post processors to apply.- Returns:
- if the post process has completed successfully
- Throws:
GestaltException- any exceptions
-
reloadNode
public GResultOf<ConfigNode> reloadNode(ConfigNodeContainer reloadNode) throws GestaltException
Description copied from interface:ConfigNodeServiceReload a node, if there are more than one node it will merge it into the config tree in the same order as the existing node. The container node has an ID so we can identity and know which node to reload to preserve order.- Specified by:
reloadNodein interfaceConfigNodeService- Parameters:
reloadNode- node to reload.- Returns:
- the new root node
- Throws:
GestaltException- any exceptions
-
navigateToNode
public GResultOf<ConfigNode> navigateToNode(java.lang.String path, java.util.List<Token> tokens, Tags tags)
Description copied from interface:ConfigNodeServicenavigate to a node for a path from the root.- Specified by:
navigateToNodein interfaceConfigNodeService- Parameters:
path- to navigate totokens- list of tokens to navigate to.tags- list of tags to match- Returns:
- GResultOf node or any errors.
-
navigateToNextNode
public GResultOf<ConfigNode> navigateToNextNode(java.lang.String path, Token token, ConfigNode currentNode)
Description copied from interface:ConfigNodeServiceFrom a given node navigate to the next node. If an ArrayToken and the config node is an ArrayNode it will return the next node by index. If a ObjectToken and the config node is a MapNode it will return the next node by key.- Specified by:
navigateToNextNodein interfaceConfigNodeService- Parameters:
path- to here for logging.token- token for the next nodecurrentNode- current node we want to navigate from- Returns:
- GResultOf node or any errors.
-
navigateToNextNode
public GResultOf<ConfigNode> navigateToNextNode(java.lang.String path, java.util.List<Token> tokens, ConfigNode currentNode)
Description copied from interface:ConfigNodeServiceFrom a given node navigate to the next node.- Specified by:
navigateToNextNodein interfaceConfigNodeService- Parameters:
path- to here for logging.tokens- list of token for the next nodecurrentNode- current node we want to navigate from- Returns:
- GResultOf node or any errors.
-
-