Class LineValidatorAggregator


  • public class LineValidatorAggregator
    extends java.lang.Object
    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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addValidator​(LineValidator validator)
      Add an validator to the aggregator.
      boolean isValid​(java.lang.String line)
      Runs all LineValidators' LineValidator.isValid(String) method against the line.
      (package private) void setValidators​(java.util.List<LineValidator> validators)
      Setter created for unit test.
      void validate​(java.lang.String line)
      Runs all LineValidators validate commands and if the string is invalid then it combines all the validation error messages in a single CsvValidationException.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LineValidatorAggregator

        public LineValidatorAggregator()
        Default constructor.
    • Method Detail

      • addValidator

        public void addValidator​(LineValidator validator)
        Add an validator to the aggregator.
        Parameters:
        validator - Validator to be added.
      • isValid

        public boolean isValid​(java.lang.String line)
        Runs all LineValidators' LineValidator.isValid(String) method against the line. This is a short circuit: as soon as one validator returns false then false is returned.
        Parameters:
        line - String to be validated.
        Returns:
        true if all validators' LineValidator.isValid(String) methods return true, false otherwise.
      • validate

        public void validate​(java.lang.String line)
                      throws CsvValidationException
        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

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