Package com.opencsv.validators
Class LineValidatorAggregator
java.lang.Object
com.opencsv.validators.LineValidatorAggregator
The aggregator's purpose is to collect multiple
LineValidators and
run them against a single line.
This way complex validations can be performed.- Since:
- 5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate List<LineValidator> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValidator(LineValidator validator) Add an validator to the aggregator.booleanRuns all LineValidators'LineValidator.isValid(String)method against the line.(package private) voidsetValidators(List<LineValidator> validators) Setter created for unit test.voidRuns all LineValidators validate commands and if the string is invalid then it combines all the validation error messages in a single CsvValidationException.
-
Field Details
-
CAPACITY
private static final int CAPACITY- See Also:
-
MULTIPLIER
private static final int MULTIPLIER- See Also:
-
validators
-
-
Constructor Details
-
LineValidatorAggregator
public LineValidatorAggregator()Default constructor.
-
-
Method Details
-
addValidator
Add an validator to the aggregator.- Parameters:
validator- Validator to be added.
-
isValid
Runs all LineValidators'LineValidator.isValid(String)method against the line. This is a short circuit: as soon as one validator returnsfalsethenfalseis returned.- Parameters:
line- String to be validated.- Returns:
trueif all validators'LineValidator.isValid(String)methods returntrue,falseotherwise.
-
validate
Runs all LineValidators validate commands and if the string is invalid then it combines all the validation error messages in a single CsvValidationException.- Parameters:
line- String to be validated- Throws:
CsvValidationException- Thrown if the string is invalid
-
setValidators
Setter created for unit test.- Parameters:
validators- - list of validators to use.
-