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

public class ConfigSpec<U> extends ConfigNode<ConfigWrapper, U>
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.
  • Method Details

    • addNode

      public ConfigSpec<U> addNode(String path, ConfigNode<?,?> node)
      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 ConfigSpec
      node -
      Returns:
      this
      Throws:
      NullPointerException - if node is null
    • addNodes

      public ConfigSpec<U> 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.
      Parameters:
      nodeMap - a map of relative paths to ConfigNodes that should be present in this ConfigSpec
      Returns:
      this
      Throws:
      NullPointerException - if nodeMap is null or contains null keys or values
    • validate

      public ConfigValidationResult validate(ConfigWrapper configWrapper)
      Convenience method that calls ConfigNode.validate(ConfigWrapper, String) with an empty string as the path argument.
      Useful when this ConfigSpec is at the root of the config.
      Parameters:
      configWrapper -
      Returns: