All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.gwdg.metadataqa.marc.analysis.validator.AbstractValidator Maven / Gradle / Ivy

package de.gwdg.metadataqa.marc.analysis.validator;

import de.gwdg.metadataqa.marc.model.validation.ValidationError;
import de.gwdg.metadataqa.marc.model.validation.ValidationErrorType;

import java.util.List;
import java.util.stream.Collectors;

abstract public class AbstractValidator {
  final ValidatorConfiguration configuration;
  List validationErrors = null;

  public AbstractValidator(ValidatorConfiguration configuration) {
    this.configuration = configuration;
  }

  /**
   * Remove ignorable errors from the list of errors
   *
   * @param errors The list of error objects
   * @return
   */
  protected List filterErrors(List errors) {
    if (configuration.getIgnorableIssueTypes() == null || configuration.getIgnorableIssueTypes().isEmpty())
      return errors;
    List filtered = errors
      .stream()
      .filter(error -> !configuration.getIgnorableIssueTypes().contains(error.getType()))
      .collect(Collectors.toList());
    return filtered;
  }

  public List getValidationErrors() {
    return validationErrors;
  }

  protected boolean isIgnorableType(ValidationErrorType type) {
    return (
          configuration.getIgnorableIssueTypes() != null
       && !configuration.getIgnorableIssueTypes().isEmpty()
       && configuration.getIgnorableIssueTypes().contains(type)
    );
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy