diff --git a/src/main/java/gr/uom/java/xmi/diff/ClassMoveComparator.java b/src/main/java/gr/uom/java/xmi/diff/ClassMoveComparator.java index a43f13fe7..db20b35ab 100644 --- a/src/main/java/gr/uom/java/xmi/diff/ClassMoveComparator.java +++ b/src/main/java/gr/uom/java/xmi/diff/ClassMoveComparator.java @@ -1,6 +1,7 @@ package gr.uom.java.xmi.diff; import java.util.Comparator; +import java.util.Set; public class ClassMoveComparator implements Comparator { @@ -12,6 +13,11 @@ public int compare(UMLClassMoveDiff o1, UMLClassMoveDiff o2) { return -Integer.compare(matchedMembers1, matchedMembers2); } else { + Set set1 = o1.commonPackagesInQualifiedName(); + Set set2 = o2.commonPackagesInQualifiedName(); + if(set1.size() != set2.size()) { + return -Integer.compare(set1.size(), set2.size()); + } double sourceFolderDistance1 = o1.getMovedClass().normalizedSourceFolderDistance(o1.getOriginalClass()); double sourceFolderDistance2 = o2.getMovedClass().normalizedSourceFolderDistance(o2.getOriginalClass()); if(sourceFolderDistance1 != sourceFolderDistance2) { diff --git a/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java b/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java index 7974c770a..49a2bc9f7 100644 --- a/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java +++ b/src/main/java/gr/uom/java/xmi/diff/UMLAbstractClassDiff.java @@ -3,6 +3,7 @@ import static gr.uom.java.xmi.Constants.JAVA; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; @@ -188,6 +189,14 @@ public UMLModelDiff getModelDiff() { return modelDiff; } + public Set commonPackagesInQualifiedName() { + List packages1 = Arrays.asList(originalClass.getName().split("\\.")); + List packages2 = Arrays.asList(nextClass.getName().split("\\.")); + Set intersection = new LinkedHashSet<>(packages1); + intersection.retainAll(packages2); + return intersection; + } + protected void processAnnotations() { this.annotationListDiff = new UMLAnnotationListDiff(originalClass.getAnnotations(), nextClass.getAnnotations()); for(UMLAnnotation annotation : annotationListDiff.getAddedAnnotations()) {