Package com.opencsv.validators
Class LineValidatorAggregator
java.lang.Object
com.opencsv.validators.LineValidatorAggregator
The aggregator's purpose is to collect multiple
LineValidator
s and
run them against a single line.
This way complex validations can be performed.- Since:
- 5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private List
<LineValidator> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addValidator
(LineValidator validator) Add an validator to the aggregator.boolean
Runs all LineValidators'LineValidator.isValid(String)
method against the line.(package private) void
setValidators
(List<LineValidator> validators) Setter created for unit test.void
Runs 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 returnsfalse
thenfalse
is returned.- Parameters:
line
- String to be validated.- Returns:
true
if all validators'LineValidator.isValid(String)
methods returntrue
,false
otherwise.
-
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.
-