@@ -31,11 +31,14 @@ public UMLAnnotationListDiff(List<UMLAnnotation> annotations1, List<UMLAnnotatio
3131 }
3232 if (!found ) {
3333 for (UMLAnnotation annotation2 : annotations2 ) {
34- if (annotation1 .getTypeName ().equals (annotation2 .getTypeName ())) {
34+ if (annotation1 .getTypeName ().equals (annotation2 .getTypeName ()) && ! alreadyMatchedAnnotation2 ( annotation2 , matchedAnnotations ) ) {
3535 matchedAnnotations .add (Pair .of (annotation1 , annotation2 ));
3636 found = true ;
3737 break ;
3838 }
39+ if (matchedAnnotations .contains (Pair .of (annotation1 , annotation2 ))) {
40+ found = true ;
41+ }
3942 }
4043 }
4144 if (!found ) {
@@ -53,11 +56,14 @@ public UMLAnnotationListDiff(List<UMLAnnotation> annotations1, List<UMLAnnotatio
5356 }
5457 if (!found ) {
5558 for (UMLAnnotation annotation1 : annotations1 ) {
56- if (annotation1 .getTypeName ().equals (annotation2 .getTypeName ())) {
59+ if (annotation1 .getTypeName ().equals (annotation2 .getTypeName ()) && ! alreadyMatchedAnnotation1 ( annotation1 , matchedAnnotations ) ) {
5760 matchedAnnotations .add (Pair .of (annotation1 , annotation2 ));
5861 found = true ;
5962 break ;
6063 }
64+ if (matchedAnnotations .contains (Pair .of (annotation1 , annotation2 ))) {
65+ found = true ;
66+ }
6167 }
6268 }
6369 if (!found ) {
@@ -75,6 +81,24 @@ else if(!commonAnnotations.contains(pair)){
7581 }
7682 }
7783
84+ private static boolean alreadyMatchedAnnotation1 (UMLAnnotation annotation1 , Set <Pair <UMLAnnotation , UMLAnnotation >> matchedAnnotations ) {
85+ for (Pair <UMLAnnotation , UMLAnnotation > pair : matchedAnnotations ) {
86+ if (pair .getLeft ().equals (annotation1 )) {
87+ return true ;
88+ }
89+ }
90+ return false ;
91+ }
92+
93+ private static boolean alreadyMatchedAnnotation2 (UMLAnnotation annotation2 , Set <Pair <UMLAnnotation , UMLAnnotation >> matchedAnnotations ) {
94+ for (Pair <UMLAnnotation , UMLAnnotation > pair : matchedAnnotations ) {
95+ if (pair .getRight ().equals (annotation2 )) {
96+ return true ;
97+ }
98+ }
99+ return false ;
100+ }
101+
78102 public Set <UMLAnnotation > getRemovedAnnotations () {
79103 return removedAnnotations ;
80104 }
0 commit comments