Class ConfigNode<T,U>

java.lang.Object
io.github.ttno1.configvalidation.ConfigNode<T,U>
Type Parameters:
T - the data type of this node
U - the output type of this ConfigNodes's filter.
Direct Known Subclasses:
ConfigList, ConfigSpec

public class ConfigNode<T,U> extends Object
Represents a node that should exist in a configuration.
Specifies a data type and a filter that a configuration node should match.
When a node is validated against a ConfigWrapper, the type of the node is verified to be correct and the filter is confirmed to have passed.
  • Method Details

    • withFilter

      public <V> ConfigNode<T,V> withFilter(ConfigFilter<U,V> filter)
      Convenience method that returns a new ConfigNode with the provided filter appended onto the current filter using ConfigFilter.withFilter(ConfigFilter).
      Type Parameters:
      V - the return type of the new filter
      Parameters:
      filter - the filter to append to the current filter
      Returns:
      a new ConfigNode with the provided filter appended onto the current filter
    • thenRun

      public ConfigNode<T,U> thenRun(Consumer<U> consumer)
      Convenience method that returns a new ConfigNode with the provided consumer appended onto the current filter akin to ConfigFilter.thenRun(Consumer).
      Parameters:
      consumer - the consumer to append to the current filter
      Returns:
      a new ConfigNode with the provided consumer appended onto the current filter
    • validate

      public ConfigValidationResult validate(ConfigWrapper configWrapper, String path)
      Validates this node against the supplied ConfigWrapper at the specified path.
      Checks for existence of the node, valid data type, and filter passage.
      Parameters:
      configWrapper - the ConfigWrapper to validate against
      path - the absolute path of this node in the ConfigWrapper
      Returns:
      a ConfigValidationResult containing whether the validation was successful and a fail message if it failed
      Throws:
      NullPointerException - if configWrapper or path are null