se.bjurr.violations.lib.ViolationsAccumulatedReporterApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of violations-lib Show documentation
Show all versions of violations-lib Show documentation
Library for parsing report files from static code analyzis.
package se.bjurr.violations.lib;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Ordering.from;
import static se.bjurr.violations.lib.model.SEVERITY.INFO;
import java.util.List;
import se.bjurr.violations.lib.model.SEVERITY;
import se.bjurr.violations.lib.model.Violation;
import com.google.common.base.Predicate;
public class ViolationsAccumulatedReporterApi {
private final List violations = newArrayList();
private SEVERITY atLeastSeverity = INFO;
private ORDERED_BY orderedBy;
private ViolationsAccumulatedReporterApi() {
}
public ViolationsAccumulatedReporterApi withViolationsReporterApiList(List violations) {
this.violations.addAll(violations);
return this;
}
public static ViolationsAccumulatedReporterApi violationsAccumulatedReporterApi() {
return new ViolationsAccumulatedReporterApi();
}
public ViolationsAccumulatedReporterApi withAtLeastSeverity(SEVERITY atLeastSeverity) {
this.atLeastSeverity = atLeastSeverity;
return this;
}
public ViolationsAccumulatedReporterApi orderedBy(ORDERED_BY orderedBy) {
this.orderedBy = orderedBy;
return this;
}
public List violations() {
return from(orderedBy.getComparator())//
.sortedCopy(//
filter(violations, new Predicate() {
@Override
public boolean apply(Violation input) {
return input.getSeverity().ordinal() >= atLeastSeverity.ordinal();
}
}));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy