diff options
author | Julien Eluard <[email protected]> | 2010-11-19 14:27:35 +0100 |
---|---|---|
committer | Julien Eluard <[email protected]> | 2010-11-19 14:27:35 +0100 |
commit | b61abf614ac91f0efe8416b8066009f7796928ab (patch) | |
tree | b8112209ae071241d8d8a80207ad9a751525c26a /api | |
parent | 6f0d6b9537143bb301d5ca74439b13458cd3a22c (diff) |
Refactoring.
Diffstat (limited to 'api')
-rw-r--r-- | api/src/main/java/org/semver/Comparer.java | 4 | ||||
-rw-r--r-- | api/src/main/java/org/semver/jardiff/DifferenceAccumulatingHandler.java (renamed from api/src/main/java/org/semver/jardiff/AccumulatingDiffHandler.java) | 32 |
2 files changed, 20 insertions, 16 deletions
diff --git a/api/src/main/java/org/semver/Comparer.java b/api/src/main/java/org/semver/Comparer.java index 9182960..1164779 100644 --- a/api/src/main/java/org/semver/Comparer.java +++ b/api/src/main/java/org/semver/Comparer.java @@ -26,7 +26,7 @@ import javax.annotation.concurrent.NotThreadSafe; import org.osjava.jardiff.DiffException; import org.osjava.jardiff.JarDiff; import org.osjava.jardiff.SimpleDiffCriteria; -import org.semver.jardiff.AccumulatingDiffHandler; +import org.semver.jardiff.DifferenceAccumulatingHandler; import org.semver.Delta.Difference; /** @@ -65,7 +65,7 @@ public class Comparer { final JarDiff jarDiff = new JarDiff(); jarDiff.loadOldClasses(this.previousJAR); jarDiff.loadNewClasses(this.currentJAR); - final AccumulatingDiffHandler handler = new AccumulatingDiffHandler(this.includes, this.excludes); + final DifferenceAccumulatingHandler handler = new DifferenceAccumulatingHandler(this.includes, this.excludes); jarDiff.diff(handler, new SimpleDiffCriteria()); return handler.getDelta(); } catch (DiffException e) { diff --git a/api/src/main/java/org/semver/jardiff/AccumulatingDiffHandler.java b/api/src/main/java/org/semver/jardiff/DifferenceAccumulatingHandler.java index a0582de..5d32424 100644 --- a/api/src/main/java/org/semver/jardiff/AccumulatingDiffHandler.java +++ b/api/src/main/java/org/semver/jardiff/DifferenceAccumulatingHandler.java @@ -36,25 +36,29 @@ import org.semver.Delta.Remove; /** * - * {@link org.osjava.jardiff.DiffHandler} implementation accumulating changes. + * {@link org.osjava.jardiff.DiffHandler} implementation accumulating {@link Difference}. * */ -public final class AccumulatingDiffHandler extends AbstractDiffHandler { +public final class DifferenceAccumulatingHandler extends AbstractDiffHandler { private String currentClassName; private final Set<String> includes; private final Set<String> excludes; private final Set<Difference> differences = new HashSet<Difference>(); - public AccumulatingDiffHandler() { + public DifferenceAccumulatingHandler() { this(Collections.<String>emptySet(), Collections.<String>emptySet()); } - public AccumulatingDiffHandler(@Nonnull final Set<String> includes, @Nonnull final Set<String> excludes) { + public DifferenceAccumulatingHandler(@Nonnull final Set<String> includes, @Nonnull final Set<String> excludes) { this.includes = includes; this.excludes = excludes; } + public String getCurrentClassName() { + return this.currentClassName; + } + @Override public void startDiff(final String previous, final String current) throws DiffException { } @@ -102,7 +106,7 @@ public final class AccumulatingDiffHandler extends AbstractDiffHandler { return; } - this.differences.add(new Add(this.currentClassName, fieldInfo)); + this.differences.add(new Add(getCurrentClassName(), fieldInfo)); } @Override @@ -111,7 +115,7 @@ public final class AccumulatingDiffHandler extends AbstractDiffHandler { return; } - this.differences.add(new Add(this.currentClassName, methodInfo)); + this.differences.add(new Add(getCurrentClassName(), methodInfo)); } @Override @@ -133,7 +137,7 @@ public final class AccumulatingDiffHandler extends AbstractDiffHandler { return; } - this.differences.add(new Change(this.currentClassName, oldClassInfo, newClassInfo)); + this.differences.add(new Change(getClassName(oldClassInfo.getName()), oldClassInfo, newClassInfo)); } @Override @@ -142,7 +146,7 @@ public final class AccumulatingDiffHandler extends AbstractDiffHandler { return; } - this.differences.add(new Change(this.currentClassName, oldFieldInfo, newFieldInfo)); + this.differences.add(new Change(getCurrentClassName(), oldFieldInfo, newFieldInfo)); } @Override @@ -151,7 +155,7 @@ public final class AccumulatingDiffHandler extends AbstractDiffHandler { return; } - this.differences.add(new Change(this.currentClassName, oldMethodInfo, newMethodInfo)); + this.differences.add(new Change(getCurrentClassName(), oldMethodInfo, newMethodInfo)); } @Override @@ -172,7 +176,7 @@ public final class AccumulatingDiffHandler extends AbstractDiffHandler { return; } - this.differences.add(new Remove(this.currentClassName, classInfo)); + this.differences.add(new Remove(getClassName(classInfo.getName()), classInfo)); } @Override @@ -181,7 +185,7 @@ public final class AccumulatingDiffHandler extends AbstractDiffHandler { return; } - this.differences.add(new Remove(this.currentClassName, fieldInfo)); + this.differences.add(new Remove(getCurrentClassName(), fieldInfo)); } @Override @@ -190,7 +194,7 @@ public final class AccumulatingDiffHandler extends AbstractDiffHandler { return; } - this.differences.add(new Remove(this.currentClassName, methodInfo)); + this.differences.add(new Remove(getCurrentClassName(), methodInfo)); } @Override @@ -209,14 +213,14 @@ public final class AccumulatingDiffHandler extends AbstractDiffHandler { */ private boolean isConsidered() { for (final String exclude : this.excludes) { - if (this.currentClassName.startsWith(exclude)) { + if (getCurrentClassName().startsWith(exclude)) { return false; } } if (!this.includes.isEmpty()) { for (final String include : this.includes) { - if (this.currentClassName.startsWith(include)) { + if (getCurrentClassName().startsWith(include)) { return true; } } |