本文整理汇总了Java中org.eclipse.emf.compare.Comparison.getMatches方法的典型用法代码示例。如果您正苦于以下问题:Java Comparison.getMatches方法的具体用法?Java Comparison.getMatches怎么用?Java Comparison.getMatches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.compare.Comparison
的用法示例。
在下文中一共展示了Comparison.getMatches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postMatch
import org.eclipse.emf.compare.Comparison; //导入方法依赖的package包/类
@Override
public void postMatch(Comparison comparison, Monitor monitor) {
final List<Match> matches = new ArrayList<>(comparison.getMatches());
final List<Match> treatedMatches = new ArrayList<>();
matches.forEach(m1 -> {
matches.forEach(m2 -> {
if (m1 != m2 && !treatedMatches.contains(m2)) {
final EObject left;
final EObject right;
if (m1.getLeft() != null && m1.getRight() == null && m2.getLeft() == null
&& m2.getRight() != null) {
left = m1.getLeft();
right = m2.getRight();
} else if (m2.getLeft() != null && m2.getRight() == null && m1.getLeft() == null
&& m1.getRight() != null) {
left = m2.getLeft();
right = m1.getRight();
} else {
return;
}
final String leftId = getIdFunction.apply(left);
final String rightId = getIdFunction.apply(right);
if (leftId.equals(rightId)) {
comparison.getMatches().remove(m1);
comparison.getMatches().remove(m2);
final Match match = new MatchSpec();
match.setLeft(left);
match.setRight(right);
comparison.getMatches().add(match);
}
}
});
treatedMatches.add(m1);
});
}
示例2: printComparisonResults
import org.eclipse.emf.compare.Comparison; //导入方法依赖的package包/类
private static void printComparisonResults(Comparison comparison){
try {
FileOutputStream fos = new FileOutputStream("produced" + File.separator + System.currentTimeMillis() + ".txt", true);
PrintStream printStream = new PrintStream(fos);
for(Match match : comparison.getMatches()){
if(match.getLeft() != null && match.getRight() != null){
System.out.println(((ENamedElement)match.getLeft()).getName() + " [" + match.getLeft().getClass() + "]");
System.out.println(((ENamedElement)match.getRight()).getName() + " [" + match.getRight().getClass() + "]");
System.out.println();
printStream.println(((ENamedElement)match.getLeft()).getName() + " [" + match.getLeft().getClass() + "]");
printStream.println(((ENamedElement)match.getRight()).getName() + " [" + match.getRight().getClass() + "]");
printStream.println();
}
for(Match submatch : match.getAllSubmatches()){
if(submatch.getLeft() != null && submatch.getRight() != null){
System.out.println("\t" + ((ENamedElement)submatch.getLeft().eContainer()).getName() + " [" + submatch.getLeft().eContainer().getClass() + "]");
System.out.println("\t\t" + ((ENamedElement)submatch.getLeft()).getName() + " [" + submatch.getLeft().getClass() + "]");
System.out.println("\t" + ((ENamedElement)submatch.getRight().eContainer()).getName() + "[" + submatch.getRight().eContainer().getClass() + "]");
System.out.println("\t\t" + ((ENamedElement)submatch.getRight()).getName() + " [" + submatch.getRight().getClass() + "]");
System.out.println();
printStream.println("\t" + ((ENamedElement)submatch.getLeft().eContainer()).getName() + " [" + submatch.getLeft().eContainer().getClass() + "]");
printStream.println("\t\t" + ((ENamedElement)submatch.getLeft()).getName() + " [" + submatch.getLeft().getClass() + "]");
printStream.println("\t" + ((ENamedElement)submatch.getRight().eContainer()).getName() + " [" + submatch.getRight().eContainer().getClass() + "]");
printStream.println("\t\t" + ((ENamedElement)submatch.getRight()).getName() + " [" + submatch.getRight().getClass() + "]");
printStream.println();
}
}
}
printStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
示例3: evaluateComparisonResult
import org.eclipse.emf.compare.Comparison; //导入方法依赖的package包/类
private static double evaluateComparisonResult(Comparison comparison) {
List<Match> matches = comparison.getMatches();
int total = matches.size();
int counter = 0;
for (Match match : matches) {
List<Match> lm = Lists.newArrayList(match.getAllSubmatches());
total += lm.size();
for (Match match2 : lm)
if (match2.getLeft() != null && match2.getRight() != null)
counter++;
if (match.getLeft() != null && match.getRight() != null)
counter++;
}
return (counter * 1.0) / total;
}