本文整理匯總了Java中org.eclipse.emf.compare.CompareFactory類的典型用法代碼示例。如果您正苦於以下問題:Java CompareFactory類的具體用法?Java CompareFactory怎麽用?Java CompareFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CompareFactory類屬於org.eclipse.emf.compare包,在下文中一共展示了CompareFactory類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createMatchesForRightElements
import org.eclipse.emf.compare.CompareFactory; //導入依賴的package包/類
/**
* Create match objects with only right references set for a list of new elements.
*
* @param elements
* The new (right) elements.
* @return The prepared elements.
*/
private List<Match> createMatchesForRightElements(List<EObject> elements) {
List<Match> rightMatches = Lists.newArrayList();
for (EObject element : elements) {
Match match = CompareFactory.eINSTANCE.createMatch();
match.setRight(element);
rightMatches.add(match);
}
return rightMatches;
}
示例2: createComparison
import org.eclipse.emf.compare.CompareFactory; //導入依賴的package包/類
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.compare.match.IComparisonFactory#createComparison()
*/
private Comparison createComparison() {
Comparison comparison = CompareFactory.eINSTANCE.createComparison();
comparison.eAdapters().add(equalityHelper);
equalityHelper.setTarget(comparison);
return comparison;
}
示例3: diffSoftwareModels
import org.eclipse.emf.compare.CompareFactory; //導入依賴的package包/類
@Override
public Comparison diffSoftwareModels(List<String> differIds, ResourceSet leadingModel,
ResourceSet integrationModel, Map<String, String> diffingOptions) throws DiffingException {
if (differIds.size() == 0) {
throw new DiffingException(String.format(MSG_DIFFER_NOT_SELECTED));
}
Comparison diffModel = CompareFactory.eINSTANCE.createComparison();
diffModel.setThreeWay(false);
for (String differId : differIds) {
Differ differ = DifferRegistry.getInstance().getElementById(differId);
if (differ == null) {
logger.warn("Selected Differ not registered: " + differId);
continue;
}
Comparison partComparisonModel;
try {
partComparisonModel = differ.doDiff(leadingModel, integrationModel, diffingOptions);
diffModel.getMatches().addAll(partComparisonModel.getMatches());
diffModel.getMatchedResources().addAll(partComparisonModel.getMatchedResources());
} catch (DiffingNotSupportedException e) {
logger.info("The differ does not support the provided input");
}
}
return diffModel;
}
示例4: testSave
import org.eclipse.emf.compare.CompareFactory; //導入依賴的package包/類
/**
* Save a model and ensure the model file exists afterwards.
*
* @throws IOException
* The model file could not be successfully writte.
*/
@Test
public void testSave() throws IOException {
File modelFilePath = new File(folder.getRoot().getAbsolutePath() + File.separator + "testmodelsave.diff");
Comparison model = CompareFactory.eINSTANCE.createComparison();
Diff diff = CompareFactory.eINSTANCE.createDiff();
model.getDifferences().add(diff);
DiffingModelUtil.save(model, modelFilePath);
assertThat(modelFilePath.exists(), is(true));
}
示例5: postMatch
import org.eclipse.emf.compare.CompareFactory; //導入依賴的package包/類
@Override
public void postMatch(Comparison comparison, Monitor monitor) {
LinkedList<Match> queue = Lists.newLinkedList(comparison.getMatches());
while (!queue.isEmpty()) {
Match currentMatch = queue.pop();
queue.addAll(currentMatch.getSubmatches());
if (currentMatch.getLeft() != null && currentMatch.getRight() != null) {
continue;
}
ValueAccessor originalValueAccessor = currentMatch.getLeft() != null ? new LeftValueAccessor()
: new RightValueAccessor();
ValueAccessor candidateValueAccessor = currentMatch.getLeft() != null ? new RightValueAccessor()
: new LeftValueAccessor();
EObject value = originalValueAccessor.getValue(currentMatch);
EReference valueReference = value.eContainmentFeature();
EClass valueClass = value.eClass();
Match parentMatch = (Match) currentMatch.eContainer();
Set<Match> candidates = parentMatch.getSubmatches().stream()
.filter(m -> originalValueAccessor.getValue(m) == null)
.filter(m -> candidateValueAccessor.getValue(m) != null)
.map(m -> Pair.create(m, candidateValueAccessor.getValue(m)))
.filter(m -> valueClass.isSuperTypeOf(m.getElement2().eClass()))
.filter(m -> valueReference == m.getElement2().eContainmentFeature()).map(m -> m.getElement1())
.collect(Collectors.toSet());
if (candidates.size() != 1) {
continue;
}
Match identifiedMatch = candidates.iterator().next();
EObject identifiedValue = candidateValueAccessor.getValue(identifiedMatch);
Match newMatch = CompareFactory.eINSTANCE.createMatch();
originalValueAccessor.setValue(newMatch, value);
candidateValueAccessor.setValue(newMatch, identifiedValue);
queue.remove(identifiedMatch);
parentMatch.getSubmatches().remove(currentMatch);
parentMatch.getSubmatches().remove(identifiedMatch);
parentMatch.getSubmatches().add(newMatch);
}
}