java.lang.Object
de.bsommerfeld.pathetic.api.pathing.processing.Validators

public final class Validators extends Object
Utility class for creating and combining NodeValidationProcessor instances. This class provides factory methods for common boolean logic operations (AND, OR, NOT) to build complex validation rules from simpler, focused validators.

All composite validators created by this class will correctly propagate the Processor.initializeSearch(SearchContext) and Processor.finalizeSearch(SearchContext) lifecycle calls to their underlying child validators.

Null validator instances passed within arrays or lists to factory methods (e.g., allOf(validator1, null, validator2)) will be ignored during processing and lifecycle calls. If the main varargs array or list itself is null, it will be treated as an empty collection.

  • Method Details

    • allOf

      public static NodeValidationProcessor allOf(NodeValidationProcessor... validators)
      Creates a NodeValidationProcessor that evaluates to true if all of the provided validators evaluate to true. This operation short-circuits: evaluation stops and false is returned as soon as the first validator evaluates to false. If no validators are provided (or all are null), this validator evaluates to true.
      Parameters:
      validators - The validators to combine with an AND logic.
      Returns:
      A new NodeValidationProcessor representing the AND condition.
    • allOf

      public static NodeValidationProcessor allOf(List<NodeValidationProcessor> validators)
      Creates a NodeValidationProcessor that evaluates to true if all of the provided validators evaluate to true. This operation short-circuits: evaluation stops and false is returned as soon as the first validator evaluates to false. If the list is empty or contains only null validators, this validator evaluates to true.
      Parameters:
      validators - A list of validators to combine with an AND logic.
      Returns:
      A new NodeValidationProcessor representing the AND condition.
    • anyOf

      public static NodeValidationProcessor anyOf(NodeValidationProcessor... validators)
      Creates a NodeValidationProcessor that evaluates to true if any of the provided validators evaluate to true. This operation short-circuits: evaluation stops and true is returned as soon as the first validator evaluates to true. If no validators are provided (or all are null), this validator evaluates to false.
      Parameters:
      validators - The validators to combine with an OR logic.
      Returns:
      A new NodeValidationProcessor representing the OR condition.
    • anyOf

      public static NodeValidationProcessor anyOf(List<NodeValidationProcessor> validators)
      Creates a NodeValidationProcessor that evaluates to true if any of the provided validators evaluate to true. This operation short-circuits: evaluation stops and true is returned as soon as the first validator evaluates to true. If the list is empty or contains only null validators, this validator evaluates to false.
      Parameters:
      validators - A list of validators to combine with an OR logic.
      Returns:
      A new NodeValidationProcessor representing the OR condition.
    • noneOf

      public static NodeValidationProcessor noneOf(NodeValidationProcessor... validators)
      Creates a NodeValidationProcessor that evaluates to true if none of the provided validators evaluate to true (i.e., all evaluate to false). This operation short-circuits: evaluation stops and false is returned as soon as the first validator evaluates to true. If no validators are provided (or all are null), this validator evaluates to true.
      Parameters:
      validators - The validators to combine with a NOR logic.
      Returns:
      A new NodeValidationProcessor representing the NOR condition.
    • noneOf

      public static NodeValidationProcessor noneOf(List<NodeValidationProcessor> validators)
      Creates a NodeValidationProcessor that evaluates to true if none of the provided validators evaluate to true (i.e., all evaluate to false). This operation short-circuits: evaluation stops and false is returned as soon as the first validator evaluates to true. If the list is empty or contains only null validators, this validator evaluates to true.
      Parameters:
      validators - A list of validators to combine with a NOR logic.
      Returns:
      A new NodeValidationProcessor representing the NOR condition.
    • not

      public static NodeValidationProcessor not(NodeValidationProcessor validator)
      Creates a NodeValidationProcessor that inverts the result of the given validator. If the provided validator is null, this method will throw an IllegalArgumentException.
      Parameters:
      validator - The validator whose result is to be inverted. Must not be null.
      Returns:
      A new NodeValidationProcessor representing the NOT condition.
      Throws:
      IllegalArgumentException - if the provided validator is null.
    • alwaysTrue

      public static NodeValidationProcessor alwaysTrue()
      Returns a NodeValidationProcessor that always evaluates to true. This validator has no side effects during lifecycle calls.
      Returns:
      A singleton instance of a validator that always returns true.
    • alwaysFalse

      public static NodeValidationProcessor alwaysFalse()
      Returns a NodeValidationProcessor that always evaluates to false. This validator has no side effects during lifecycle calls.
      Returns:
      A singleton instance of a validator that always returns false.