aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/main/java/org
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-04-03 05:54:12 +0200
committerSven Gothel <[email protected]>2015-04-03 05:54:12 +0200
commit45e18a543f7f11bf5e701f898e7c1221bd2f2672 (patch)
tree5d57d9e31fd109986650873f7b01f2a6395703a3 /api/src/main/java/org
parentc714666c0f4e19bb9db163f576e28d36cad7df74 (diff)
Expose 'fieldCompatChanged', allowing user to fail if fields have changed (binary compatible)
Diffstat (limited to 'api/src/main/java/org')
-rwxr-xr-xapi/src/main/java/org/semver/Delta.java17
-rwxr-xr-xapi/src/main/java/org/semver/jardiff/DifferenceAccumulatingHandler.java6
2 files changed, 18 insertions, 5 deletions
diff --git a/api/src/main/java/org/semver/Delta.java b/api/src/main/java/org/semver/Delta.java
index e148a72..6ef79fd 100755
--- a/api/src/main/java/org/semver/Delta.java
+++ b/api/src/main/java/org/semver/Delta.java
@@ -151,9 +151,11 @@ public final class Delta {
}
private final Set<Difference> differences;
+ private final boolean fieldCompatChanged;
- public Delta(@Nonnull final Set<? extends Difference> differences) {
+ public Delta(@Nonnull final Set<? extends Difference> differences, final boolean fieldCompatChanged) {
this.differences = Collections.unmodifiableSet(differences);
+ this.fieldCompatChanged = fieldCompatChanged;
}
@Nonnull
@@ -161,9 +163,10 @@ public final class Delta {
return this.differences;
}
+ public final boolean fieldCompatChanged() { return fieldCompatChanged; }
+
/**
- * @param differences
- * @return {@link CompatibilityType} based on specified {@link Difference}
+ * @return {@link CompatibilityType} based on this {@link Delta}
*/
@Nonnull
public final CompatibilityType computeCompatibilityType() {
@@ -180,6 +183,14 @@ public final class Delta {
}
}
+ /**
+ * @param type {@link Difference} type to test
+ * @return {@code true}, if given {@link Difference} type is contained by this {@link Delta}
+ */
+ public final boolean contains(final Class<? extends Difference> type) {
+ return contains(this.differences, type);
+ }
+
protected final boolean contains(final Set<Difference> differences, final Class<? extends Difference> type) {
for (final Difference difference : differences) {
if (type.isInstance(difference)) {
diff --git a/api/src/main/java/org/semver/jardiff/DifferenceAccumulatingHandler.java b/api/src/main/java/org/semver/jardiff/DifferenceAccumulatingHandler.java
index 8f7fb22..f697ef4 100755
--- a/api/src/main/java/org/semver/jardiff/DifferenceAccumulatingHandler.java
+++ b/api/src/main/java/org/semver/jardiff/DifferenceAccumulatingHandler.java
@@ -49,6 +49,7 @@ public final class DifferenceAccumulatingHandler extends AbstractDiffHandler {
private final Set<String> excludes;
private final boolean excludesAreRegExp;
private final Set<Difference> differences = new HashSet<Difference>();
+ private boolean fieldCompatChanged;
public DifferenceAccumulatingHandler() {
this(Collections.<String>emptySet(), Collections.<String>emptySet());
@@ -63,6 +64,7 @@ public final class DifferenceAccumulatingHandler extends AbstractDiffHandler {
this.includesAreRegExp = includesAreRegExp;
this.excludes = excludes;
this.excludesAreRegExp = excludesAreRegExp;
+ this.fieldCompatChanged = false;
}
public String getCurrentClassName() {
@@ -173,7 +175,7 @@ public final class DifferenceAccumulatingHandler extends AbstractDiffHandler {
if (!isClassConsidered(getCurrentClassName())) {
return;
}
-
+ this.fieldCompatChanged = true;
this.differences.add(new CompatChange(getCurrentClassName(), oldFieldInfo, newFieldInfo));
}
@@ -354,7 +356,7 @@ public final class DifferenceAccumulatingHandler extends AbstractDiffHandler {
}
public Delta getDelta() {
- return new Delta(this.differences);
+ return new Delta(this.differences, this.fieldCompatChanged);
}
}