Class Validators
java.lang.Object
de.bsommerfeld.pathetic.api.pathing.processing.Validators
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 Summary
Modifier and TypeMethodDescriptionstatic NodeValidationProcessorallOf(NodeValidationProcessor... validators) Creates aNodeValidationProcessorthat evaluates totrueif all of the provided validators evaluate totrue.static NodeValidationProcessorallOf(List<NodeValidationProcessor> validators) Creates aNodeValidationProcessorthat evaluates totrueif all of the provided validators evaluate totrue.static NodeValidationProcessorReturns aNodeValidationProcessorthat always evaluates tofalse.static NodeValidationProcessorReturns aNodeValidationProcessorthat always evaluates totrue.static NodeValidationProcessoranyOf(NodeValidationProcessor... validators) Creates aNodeValidationProcessorthat evaluates totrueif any of the provided validators evaluate totrue.static NodeValidationProcessoranyOf(List<NodeValidationProcessor> validators) Creates aNodeValidationProcessorthat evaluates totrueif any of the provided validators evaluate totrue.static NodeValidationProcessornoneOf(NodeValidationProcessor... validators) Creates aNodeValidationProcessorthat evaluates totrueif none of the provided validators evaluate totrue(i.e., all evaluate tofalse).static NodeValidationProcessornoneOf(List<NodeValidationProcessor> validators) Creates aNodeValidationProcessorthat evaluates totrueif none of the provided validators evaluate totrue(i.e., all evaluate tofalse).static NodeValidationProcessornot(NodeValidationProcessor validator) Creates aNodeValidationProcessorthat inverts the result of the given validator.
-
Method Details
-
allOf
Creates aNodeValidationProcessorthat 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 (or all are null), this validator evaluates totrue.- Parameters:
validators- The validators to combine with an AND logic.- Returns:
- A new
NodeValidationProcessorrepresenting the AND condition.
-
allOf
Creates aNodeValidationProcessorthat 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 or contains only null validators, this validator evaluates totrue.- Parameters:
validators- A list of validators to combine with an AND logic.- Returns:
- A new
NodeValidationProcessorrepresenting the AND condition.
-
anyOf
Creates aNodeValidationProcessorthat 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 (or all are null), this validator evaluates tofalse.- Parameters:
validators- The validators to combine with an OR logic.- Returns:
- A new
NodeValidationProcessorrepresenting the OR condition.
-
anyOf
Creates aNodeValidationProcessorthat 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 or contains only null validators, this validator evaluates tofalse.- Parameters:
validators- A list of validators to combine with an OR logic.- Returns:
- A new
NodeValidationProcessorrepresenting the OR condition.
-
noneOf
Creates aNodeValidationProcessorthat 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 (or all are null), this validator evaluates totrue.- Parameters:
validators- The validators to combine with a NOR logic.- Returns:
- A new
NodeValidationProcessorrepresenting the NOR condition.
-
noneOf
Creates aNodeValidationProcessorthat 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 or contains only null validators, this validator evaluates totrue.- Parameters:
validators- A list of validators to combine with a NOR logic.- Returns:
- A new
NodeValidationProcessorrepresenting the NOR condition.
-
not
Creates aNodeValidationProcessorthat inverts the result of the given validator. If the provided validator isnull, this method will throw anIllegalArgumentException.- Parameters:
validator- The validator whose result is to be inverted. Must not be null.- Returns:
- A new
NodeValidationProcessorrepresenting the NOT condition. - Throws:
IllegalArgumentException- if the provided validator is null.
-
alwaysTrue
Returns aNodeValidationProcessorthat 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 aNodeValidationProcessorthat always evaluates tofalse. This validator has no side effects during lifecycle calls.- Returns:
- A singleton instance of a validator that always returns
false.
-