Package cdc.validation
Interface Validator<T>
- Type Parameters:
T- Value type.
- All Known Implementing Classes:
ValidatorImpl
public interface Validator<T>
Validator of values.
- Author:
- Damien Carbonne
-
Method Summary
Modifier and TypeMethodDescriptiondefault <S> Validator<S>Creates a validator composed of this one applied after a converter.default <S> Validator<S>Creates a validator composed of this one applied after a conversion function.default Validator<?>explainError(String name) Returns an explanation of the rule that must be respected to avoid errors.explainWarning(String name) Returns an explanation of the rule that must be respected to avoid warnings.default ValiditygetValidity(T value) Returns the validity of a value.default ValiditygetValidityRaw(Object value) Returns the validity of a raw value.default List<ValidationRecord>Validates a value and returns a list of validation records.voidvalidate(T value, String name, ValidationHandler handler) Validates a value.default voidvalidate(T value, String name, List<ValidationRecord> records) Validates a value and adds validation records to a list.default List<ValidationRecord>validateRaw(Object value, String name) Validates a raw value and returns a list of validation records.default voidvalidateRaw(Object value, String name, ValidationHandler handler) Validates a raw value.default voidvalidateRaw(Object value, String name, List<ValidationRecord> records) Validates a raw value and adds validation records to a list.
-
Method Details
-
getValueClass
- Returns:
- The class of values validated by this validator.
-
explainError
Returns an explanation of the rule that must be respected to avoid errors.- Parameters:
name- The name that must be given to value in messages.- Returns:
- An explanation of the rule that must be respected to avoid errors.
-
explainWarning
Returns an explanation of the rule that must be respected to avoid warnings.- Parameters:
name- The name that must be given to value in messages.- Returns:
- An explanation of the rule that must be respected to avoid warnings.
-
validate
Validates a value.- Parameters:
value- The value.name- The name that must be given tovaluein messages.handler- The validation messages handler.
-
validate
Validates a value and adds validation records to a list.- Parameters:
value- The value.name- The name that must be given tovaluein messages.records- The list of validation records that must be filled.- Throws:
IllegalArgumentException- Whenrecordsisnull.
-
validate
Validates a value and returns a list of validation records.- Parameters:
value- The value.name- The name that must be given tovaluein messages.- Returns:
- A list of validation records, possibly empty.
-
validateRaw
Validates a raw value.- Parameters:
value- The value.name- The name that must be given tovaluein messages.handler- The validation messages handler.- Throws:
ClassCastException- Ifvalueis notnulland cannot be assigned to value typeT.
-
validateRaw
Validates a raw value and adds validation records to a list.- Parameters:
value- The value.name- The name that must be given tovaluein messages.records- The list of validation records that must be filled.- Throws:
IllegalArgumentException- Whenrecordsisnull.ClassCastException- Ifvalueis notnulland cannot be assigned to value typeT.
-
validateRaw
Validates a raw value and returns a list of validation records.- Parameters:
value- The value.name- The name that must be given tovaluein messages.- Returns:
- A list of validation records, possibly empty.
- Throws:
ClassCastException- Ifvalueis notnulland cannot be assigned to value typeT.
-
getValidity
Returns the validity of a value.- Parameters:
value- The value.- Returns:
- The validity of
value.
-
getValidityRaw
Returns the validity of a raw value.- Parameters:
value- The value.- Returns:
- The validity of
value. - Throws:
ClassCastException- Ifvalueis notnulland cannot be assigned to value typeT.
-
after
Creates a validator composed of this one applied after a converter.- Type Parameters:
S- The source type.- Parameters:
converter- The converter from source typeStoT.- Returns:
- A new validator composed of this one applied after
converter. - Throws:
IllegalArgumentException- Whenconverterisnull.
-
afterRaw
- Parameters:
converter- The converter.- Returns:
- A new validator composed of this one applied after
converter. - Throws:
IllegalArgumentException- Whenconverterisnull.
-
after
Creates a validator composed of this one applied after a conversion function.- Type Parameters:
S- The source type.- Parameters:
function- The function that converts values from source typeStoT.sourceClass- The source class.- Returns:
- A new validator composed of this one applied conversion
function. - Throws:
IllegalArgumentException- WhenfunctionorsourceClassisnull.
-