-
- All Superinterfaces:
ValidationSummarizer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ValidationStatement extends ValidationSummarizer
AValidationStatementis the smallest part of a validation Process.- Author:
- mlo
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description @NotNull ValidationInfoexecute()The implementation must contain any validation logic.default @NotNull ValidationResultvalidate()Wraps the result ofexecute()in aValidationResultHas to execute one or more parts of the validation process.
-
-
-
Method Detail
-
execute
@NotNull @NotNull ValidationInfo execute()
The implementation must contain any validation logic. If the validation fails return aValidationInfowith a message, which describes the error. Use theValidationInfo.invalid(String)function in this case.
If the validation was successful you can use theValidationInfo.valid()function. This creates an information object with no message (usually the message is not important if the validation succeed, but it may help with debugging).
Example:public ValidationInfo validate(){ String name = unbindName(); if (name.isBlank()){ return ValidationInfo.invalid("Name is blank"); } return ValidationInfo.valid(); }Statementscan be grouped and chained by using aValidator- Returns:
- The information if the validation succeed or not. Check the
ValidationInfo.getMessage()if the validation failed. Returningnullwill result in aNullPointerException
-
validate
@NotNull default @NotNull ValidationResult validate()
Wraps the result ofexecute()in aValidationResult
Has to execute one or more parts of the validation process. The result of all executed parts should be returned as an aggregatedValidationResult.- Specified by:
validatein interfaceValidationSummarizer- Returns:
- A wrapped
ValidationInfo. The result contains exactly one info
-
-