From 0d2e314ef48bd2fd38b45f781c4573bdb2b32a69 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 3 Apr 2015 23:49:31 +0200 Subject: *DiffCriteria.differs[Binary](FieldInfo ..): Need to take value type into account! --- api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java | 8 ++++---- api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java | 8 ++++---- api/src/main/java/org/semver/Dumper.java | 12 ++++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'api/src/main/java/org') diff --git a/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java b/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java index c7fea4b..c5e2f02 100644 --- a/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java +++ b/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java @@ -116,13 +116,13 @@ public class PublicDiffCriteria implements DiffCriteria @Override public boolean differs(final FieldInfo oldInfo, final FieldInfo newInfo) { - return Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()) || - // Tools.isFieldTypeChange(oldInfo.getValue(), newInfo.getValue()) || + return Tools.isFieldTypeChange(oldInfo.getValue(), newInfo.getValue()) || + Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()) || Tools.isFieldValueChange(oldInfo.getValue(), newInfo.getValue()); } @Override public boolean differsBinary(final FieldInfo oldInfo, final FieldInfo newInfo) { - return Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()); // && - // Tools.isFieldTypeChange(oldInfo.getValue(), newInfo.getValue()); + return Tools.isFieldTypeChange(oldInfo.getValue(), newInfo.getValue()) || + Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()); } } diff --git a/api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java b/api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java index 062baca..09d1108 100644 --- a/api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java +++ b/api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java @@ -116,13 +116,13 @@ public class SimpleDiffCriteria implements DiffCriteria @Override public boolean differs(final FieldInfo oldInfo, final FieldInfo newInfo) { - return Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()) || - // Tools.isFieldTypeChange(oldInfo.getValue(), newInfo.getValue()) || + return Tools.isFieldTypeChange(oldInfo.getValue(), newInfo.getValue()) || + Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()) || Tools.isFieldValueChange(oldInfo.getValue(), newInfo.getValue()); } @Override public boolean differsBinary(final FieldInfo oldInfo, final FieldInfo newInfo) { - return Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()); // && - // Tools.isFieldTypeChange(oldInfo.getValue(), newInfo.getValue()); + return Tools.isFieldTypeChange(oldInfo.getValue(), newInfo.getValue()) || + Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()); } } diff --git a/api/src/main/java/org/semver/Dumper.java b/api/src/main/java/org/semver/Dumper.java index bf2448b..30824f5 100755 --- a/api/src/main/java/org/semver/Dumper.java +++ b/api/src/main/java/org/semver/Dumper.java @@ -98,9 +98,11 @@ public class Dumper { final FieldInfo fCurInfo = (FieldInfo)currentInfo; final Object preValue = fPreInfo.getValue(); final Object curValue = fCurInfo.getValue(); + final String preType = null != preValue ? preValue.getClass().getName() : "nil"; + final String curType = null != curValue ? curValue.getClass().getName() : "nil"; if (Tools.isFieldTypeChange(preValue, curValue)) { - builder.append(", type[").append(preValue.getClass()) - .append(" -> ").append(curValue.getClass()).append("]"); + builder.append(", type[").append(preType) + .append(" -> ").append(curType).append("]"); } } builder.append(", access["); @@ -138,6 +140,12 @@ public class Dumper { final FieldInfo fCurInfo = (FieldInfo)currentInfo; final Object preValue = fPreInfo.getValue(); final Object curValue = fCurInfo.getValue(); + final String preType = null != preValue ? preValue.getClass().getName() : "nil"; + final String curType = null != curValue ? curValue.getClass().getName() : "nil"; + if (Tools.isFieldTypeChange(preValue, curValue)) { + builder.append(", type[").append(preType) + .append(" -> ").append(curType).append("]"); + } if (Tools.isFieldValueChange(preValue, curValue)) { builder.append(", value[").append(preValue) .append(" -> ").append(curValue).append("]"); -- cgit v1.2.3