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

public final class Validators extends Object
Utility class for creating and combining ValidationProcessor 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 handling: Every factory method rejects null. Passing null as the varargs array, the list, or any individual element triggers a NullPointerException. There is no silent filtering; a null validator is always a caller bug.

  • Method Details

    • allOf

      public static ValidationProcessor allOf(ValidationProcessor... validators)
      Creates a ValidationProcessor 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, this validator evaluates to true.
      Parameters:
      validators - The validators to combine with an AND logic. Must not be null and must not contain null elements.
      Returns:
      A new ValidationProcessor representing the AND condition.
      Throws:
      NullPointerException - if validators or any element is null.
    • allOf

      public static ValidationProcessor allOf(List<ValidationProcessor> validators)
      Creates a ValidationProcessor 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, this validator evaluates to true.
      Parameters:
      validators - A list of validators to combine with an AND logic. Must not be null and must not contain null elements.
      Returns:
      A new ValidationProcessor representing the AND condition.
      Throws:
      NullPointerException - if validators or any element is null.
    • anyOf

      public static ValidationProcessor anyOf(ValidationProcessor... validators)
      Creates a ValidationProcessor 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, this validator evaluates to false.
      Parameters:
      validators - The validators to combine with an OR logic. Must not be null and must not contain null elements.
      Returns:
      A new ValidationProcessor representing the OR condition.
      Throws:
      NullPointerException - if validators or any element is null.
    • anyOf

      public static ValidationProcessor anyOf(List<ValidationProcessor> validators)
      Creates a ValidationProcessor 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, this validator evaluates to false.
      Parameters:
      validators - A list of validators to combine with an OR logic. Must not be null and must not contain null elements.
      Returns:
      A new ValidationProcessor representing the OR condition.
      Throws:
      NullPointerException - if validators or any element is null.
    • noneOf

      public static ValidationProcessor noneOf(ValidationProcessor... validators)
      Creates a ValidationProcessor 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, this validator evaluates to true.
      Parameters:
      validators - The validators to combine with a NOR logic. Must not be null and must not contain null elements.
      Returns:
      A new ValidationProcessor representing the NOR condition.
      Throws:
      NullPointerException - if validators or any element is null.
    • noneOf

      public static ValidationProcessor noneOf(List<ValidationProcessor> validators)
      Creates a ValidationProcessor 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, this validator evaluates to true.
      Parameters:
      validators - A list of validators to combine with a NOR logic. Must not be null and must not contain null elements.
      Returns:
      A new ValidationProcessor representing the NOR condition.
      Throws:
      NullPointerException - if validators or any element is null.
    • not

      public static ValidationProcessor not(ValidationProcessor validator)
      Creates a ValidationProcessor that inverts the result of the given validator.
      Parameters:
      validator - The validator whose result is to be inverted. Must not be null.
      Returns:
      A new ValidationProcessor representing the NOT condition.
      Throws:
      NullPointerException - if validator is null.
    • alwaysTrue

      public static ValidationProcessor alwaysTrue()
      Returns a ValidationProcessor 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 ValidationProcessor alwaysFalse()
      Returns a ValidationProcessor 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.