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

de.dagere.peass.analysis.properties.VersionChangeProperties Maven / Gradle / Ivy

There is a newer version: 0.4.0
Show newest version
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;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy