Class Validators
java.lang.Object
de.bsommerfeld.pathetic.api.pathing.processing.Validators
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 Summary
Modifier and TypeMethodDescriptionstatic ValidationProcessorallOf(ValidationProcessor... validators) Creates aValidationProcessorthat evaluates totrueif all of the provided validators evaluate totrue.static ValidationProcessorallOf(List<ValidationProcessor> validators) Creates aValidationProcessorthat evaluates totrueif all of the provided validators evaluate totrue.static ValidationProcessorReturns aValidationProcessorthat always evaluates tofalse.static ValidationProcessorReturns aValidationProcessorthat always evaluates totrue.static ValidationProcessoranyOf(ValidationProcessor... validators) Creates aValidationProcessorthat evaluates totrueif any of the provided validators evaluate totrue.static ValidationProcessoranyOf(List<ValidationProcessor> validators) Creates aValidationProcessorthat evaluates totrueif any of the provided validators evaluate totrue.static ValidationProcessornoneOf(ValidationProcessor... validators) Creates aValidationProcessorthat evaluates totrueif none of the provided validators evaluate totrue(i.e., all evaluate tofalse).static ValidationProcessornoneOf(List<ValidationProcessor> validators) Creates aValidationProcessorthat evaluates totrueif none of the provided validators evaluate totrue(i.e., all evaluate tofalse).static ValidationProcessornot(ValidationProcessor validator) Creates aValidationProcessorthat inverts the result of the given validator.
-
Method Details
-
allOf
Creates aValidationProcessorthat evaluates totrueif all of the provided validators evaluate totrue. This operation short-circuits: evaluation stops andfalseis returned as soon as the first validator evaluates tofalse. If no validators are provided, this validator evaluates totrue.- Parameters:
validators- The validators to combine with an AND logic. Must not benulland must not containnullelements.- Returns:
- A new
ValidationProcessorrepresenting the AND condition. - Throws:
NullPointerException- ifvalidatorsor any element isnull.
-
allOf
Creates aValidationProcessorthat evaluates totrueif all of the provided validators evaluate totrue. This operation short-circuits: evaluation stops andfalseis returned as soon as the first validator evaluates tofalse. If the list is empty, this validator evaluates totrue.- Parameters:
validators- A list of validators to combine with an AND logic. Must not benulland must not containnullelements.- Returns:
- A new
ValidationProcessorrepresenting the AND condition. - Throws:
NullPointerException- ifvalidatorsor any element isnull.
-
anyOf
Creates aValidationProcessorthat evaluates totrueif any of the provided validators evaluate totrue. This operation short-circuits: evaluation stops andtrueis returned as soon as the first validator evaluates totrue. If no validators are provided, this validator evaluates tofalse.- Parameters:
validators- The validators to combine with an OR logic. Must not benulland must not containnullelements.- Returns:
- A new
ValidationProcessorrepresenting the OR condition. - Throws:
NullPointerException- ifvalidatorsor any element isnull.
-
anyOf
Creates aValidationProcessorthat evaluates totrueif any of the provided validators evaluate totrue. This operation short-circuits: evaluation stops andtrueis returned as soon as the first validator evaluates totrue. If the list is empty, this validator evaluates tofalse.- Parameters:
validators- A list of validators to combine with an OR logic. Must not benulland must not containnullelements.- Returns:
- A new
ValidationProcessorrepresenting the OR condition. - Throws:
NullPointerException- ifvalidatorsor any element isnull.
-
noneOf
Creates aValidationProcessorthat evaluates totrueif none of the provided validators evaluate totrue(i.e., all evaluate tofalse). This operation short-circuits: evaluation stops andfalseis returned as soon as the first validator evaluates totrue. If no validators are provided, this validator evaluates totrue.- Parameters:
validators- The validators to combine with a NOR logic. Must not benulland must not containnullelements.- Returns:
- A new
ValidationProcessorrepresenting the NOR condition. - Throws:
NullPointerException- ifvalidatorsor any element isnull.
-
noneOf
Creates aValidationProcessorthat evaluates totrueif none of the provided validators evaluate totrue(i.e., all evaluate tofalse). This operation short-circuits: evaluation stops andfalseis returned as soon as the first validator evaluates totrue. If the list is empty, this validator evaluates totrue.- Parameters:
validators- A list of validators to combine with a NOR logic. Must not benulland must not containnullelements.- Returns:
- A new
ValidationProcessorrepresenting the NOR condition. - Throws:
NullPointerException- ifvalidatorsor any element isnull.
-
not
Creates aValidationProcessorthat inverts the result of the given validator.- Parameters:
validator- The validator whose result is to be inverted. Must not benull.- Returns:
- A new
ValidationProcessorrepresenting the NOT condition. - Throws:
NullPointerException- ifvalidatorisnull.
-
alwaysTrue
Returns aValidationProcessorthat always evaluates totrue. This validator has no side effects during lifecycle calls.- Returns:
- A singleton instance of a validator that always returns
true.
-
alwaysFalse
Returns aValidationProcessorthat always evaluates tofalse. This validator has no side effects during lifecycle calls.- Returns:
- A singleton instance of a validator that always returns
false.
-