Class ConfigSpec<U>
java.lang.Object
io.github.ttno1.configvalidation.ConfigNode<ConfigWrapper, U>
io.github.ttno1.configvalidation.ConfigSpec<U>
- Type Parameters:
U
- the return type of the filter of this ConfigSpec
A Configuration Specification that specifies various ConfigNodes that must be present in a configuration.
This class is used to validate a config with many nodes.
Specifies list of nodes and their corresponding locations (paths) in the configuration.
When a ConfigSpec is validated against a ConfigWrapper, each of its contained nodes are validated as well.
This class is used to validate a config with many nodes.
Specifies list of nodes and their corresponding locations (paths) in the configuration.
When a ConfigSpec is validated against a ConfigWrapper, each of its contained nodes are validated as well.
-
Method Summary
Modifier and TypeMethodDescriptionaddNode
(String path, ConfigNode<?, ?> node) Adds the node to this ConfigSpec at the specified path.
Replaces any node that was previously at the specified path.addNodes
(Map<String, ConfigNode<?, ?>> nodeMap) Adds the specified nodes to this ConfigSpec at their corresponding paths.
Replaces any nodes that were previously at any specified paths.validate
(ConfigWrapper configWrapper) Convenience method that callsConfigNode.validate(ConfigWrapper, String)
with an empty string as the path argument.
Useful when thisConfigSpec
is at the root of the config.Methods inherited from class io.github.ttno1.configvalidation.ConfigNode
thenRun, validate, withFilter
-
Method Details
-
addNode
Adds the node to this ConfigSpec at the specified path.
Replaces any node that was previously at the specified path.- Parameters:
path
- the path of the provided node relative to the root path of this ConfigSpecnode
-- Returns:
this
- Throws:
NullPointerException
- ifnode
is null
-
addNodes
Adds the specified nodes to this ConfigSpec at their corresponding paths.
Replaces any nodes that were previously at any specified paths.- Parameters:
nodeMap
- a map of relative paths toConfigNode
s that should be present in this ConfigSpec- Returns:
this
- Throws:
NullPointerException
- ifnodeMap
is null or contains null keys or values
-
validate
Convenience method that callsConfigNode.validate(ConfigWrapper, String)
with an empty string as the path argument.
Useful when thisConfigSpec
is at the root of the config.- Parameters:
configWrapper
-- Returns:
-