Class RowValidatorAggregator

java.lang.Object
com.opencsv.validators.RowValidatorAggregator

public class RowValidatorAggregator extends Object
The aggregator's purpose is to collect multiple RowValidators and run them against a single array of strings. This way complex validations can be performed.
Since:
5.0
  • Field Details

  • Constructor Details

    • RowValidatorAggregator

      public RowValidatorAggregator()
      Default constructor.
  • Method Details

    • addValidator

      public void addValidator(RowValidator validator)
      Add a validator to the aggregator.
      Parameters:
      validator - Validator to be added.
    • isValid

      public boolean isValid(String[] row)
      Runs all RowValidators' RowValidator.isValid(String[]) method against the line. This is a short circuit: as soon as one validator returns false then false is returned.
      Parameters:
      row - Array of strings to be validated.
      Returns:
      true if all validators' RowValidator.isValid(String[]) methods return true, false otherwise.
    • validate

      public void validate(String[] row) throws CsvValidationException
      Runs all RowValidators' RowValidator.validate(String[]) methods and if the string array is invalid, then it combines all the validation error messages in a single CsvValidationException.
      Parameters:
      row - Array of Strings to be validation.
      Throws:
      CsvValidationException - Thrown if the string is invalid.
    • setValidators

      void setValidators(List<RowValidator> validators)
      Setter created for unit test.
      Parameters:
      validators - - list of validators to use.