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

se.bjurr.violations.lib.ViolationsApi Maven / Gradle / Ivy

There is a newer version: 1.157.3
Show newest version
package se.bjurr.violations.lib;

import static se.bjurr.violations.lib.reports.ReportsFinder.findAllReports;

import java.io.File;
import java.util.List;

import se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.lib.reports.Reporter;

public class ViolationsApi {
 private String pattern;
 private Reporter reporter;
 private File startFile;

 private ViolationsApi() {
 }

 public static ViolationsApi violationsApi() {
  return new ViolationsApi();
 }

 public ViolationsApi withPattern(String regularExpression) {
  this.pattern = regularExpression;
  return this;
 }

 public ViolationsApi findAll(Reporter reporter) {
  this.reporter = reporter;
  return this;
 }

 public ViolationsApi inFolder(String folder) {
  this.startFile = new File(folder);
  if (!startFile.exists()) {
   throw new RuntimeException(folder + " not found");
  }
  return this;
 }

 public List violations() {
  List includedFiles = findAllReports(startFile, pattern);
  return reporter.findViolations(includedFiles);
 }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy