gr.uom.java.xmi.diff.UMLAnnotationListDiff Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of refactoring-miner Show documentation
Show all versions of refactoring-miner Show documentation
RefactoringMiner is a library/API written in Java that can detect refactorings applied in the history of a Java project.
package gr.uom.java.xmi.diff;
import java.util.List;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import gr.uom.java.xmi.UMLAnnotation;
public class UMLAnnotationListDiff {
private List removedAnnotations;
private List addedAnnotations;
private List annotationDiffList;
public UMLAnnotationListDiff(List annotations1, List annotations2) {
this.removedAnnotations = new ArrayList();
this.addedAnnotations = new ArrayList();
this.annotationDiffList = new ArrayList();
List> matchedAnnotations = new ArrayList>();
for(UMLAnnotation annotation1 : annotations1) {
boolean found = false;
for(UMLAnnotation annotation2 : annotations2) {
if(annotation1.getTypeName().equals(annotation2.getTypeName())) {
matchedAnnotations.add(new SimpleEntry(annotation1, annotation2));
found = true;
break;
}
}
if(!found) {
removedAnnotations.add(annotation1);
}
}
for(UMLAnnotation annotation2 : annotations2) {
boolean found = false;
for(UMLAnnotation annotation1 : annotations1) {
if(annotation1.getTypeName().equals(annotation2.getTypeName())) {
matchedAnnotations.add(new SimpleEntry(annotation1, annotation2));
found = true;
break;
}
}
if(!found) {
addedAnnotations.add(annotation2);
}
}
for(SimpleEntry entry : matchedAnnotations) {
UMLAnnotationDiff annotationDiff = new UMLAnnotationDiff(entry.getKey(), entry.getValue());
if(!annotationDiff.isEmpty()) {
annotationDiffList.add(annotationDiff);
}
}
}
public List getRemovedAnnotations() {
return removedAnnotations;
}
public List getAddedAnnotations() {
return addedAnnotations;
}
public List getAnnotationDiffList() {
return annotationDiffList;
}
public boolean isEmpty() {
return removedAnnotations.isEmpty() && addedAnnotations.isEmpty() && annotationDiffList.isEmpty();
}
}