de.dagere.peass.analysis.properties.VersionChangeProperties Maven / Gradle / Ivy
package de.dagere.peass.analysis.properties;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import com.fasterxml.jackson.annotation.JsonIgnore;
import de.dagere.peass.dependencyprocessors.VersionComparator;
public class VersionChangeProperties {
private Map versions = VersionComparator.hasDependencies() ? new TreeMap<>(VersionComparator.INSTANCE) : new LinkedHashMap<>();
public Map getVersions() {
return versions;
}
public void setVersions(final Map versionProperties) {
this.versions = versionProperties;
}
public void executeProcessor(final PropertyProcessor c) {
for (final Entry version : versions.entrySet()) {
for (final Entry> testcase : version.getValue().getProperties().entrySet()) {
for (final ChangeProperty change : testcase.getValue()) {
c.process(version.getKey(), testcase.getKey(), change, version.getValue());
}
}
}
}
final class Counter implements PropertyProcessor {
int count = 0;
@Override
public void process(final String version, final String testcase, final ChangeProperty change, final ChangeProperties changeProperties) {
if (change.isAffectsSource() && !change.isAffectsTestSource()) {
count++;
}
}
};
@JsonIgnore
public int getSourceChanges() {
final Counter counter = new Counter();
executeProcessor(counter);
return counter.count;
}
}