本文整理汇总了Java中org.eclipse.emf.compare.Comparison.getMatch方法的典型用法代码示例。如果您正苦于以下问题:Java Comparison.getMatch方法的具体用法?Java Comparison.getMatch怎么用?Java Comparison.getMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.compare.Comparison
的用法示例。
在下文中一共展示了Comparison.getMatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMatchingObjects
import org.eclipse.emf.compare.Comparison; //导入方法依赖的package包/类
protected List<EObject> findMatchingObjects(final EObject model, final Collection<EObject> objects) {
boolean _isEmpty = objects.isEmpty();
if (_isEmpty) {
throw new IllegalArgumentException();
}
Resource _eResource = model.eResource();
EObject _head = IterableExtensions.<EObject>head(objects);
Resource _eResource_1 = _head.eResource();
final DefaultComparisonScope scope = new DefaultComparisonScope(_eResource, _eResource_1, null);
EMFCompare.Builder _builder = EMFCompare.builder();
EMFCompare _build = _builder.build();
final Comparison comparison = _build.compare(scope);
final Function1<EObject, EObject> _function = new Function1<EObject, EObject>() {
@Override
public EObject apply(final EObject object) {
Match _match = comparison.getMatch(object);
return _match.getLeft();
}
};
Iterable<EObject> _map = IterableExtensions.<EObject, EObject>map(objects, _function);
Iterable<EObject> _filterNull = IterableExtensions.<EObject>filterNull(_map);
return IterableExtensions.<EObject>toList(_filterNull);
}
示例2: updateEObjectLocation
import org.eclipse.emf.compare.Comparison; //导入方法依赖的package包/类
/**
* Updates the given {@link IEObjectLocation}.
*
* @param oldResource
* the old {@link Resource}
* @param comparison
* the {@link Comparison}
* @param eObjectlocation
* the {@link IEObjectLocation}
* @param useSaveURIFragment
* tells if we should use {@link IEObjectLocation#getSavedURIFragment()}
* @throws Exception
* if {@link org.eclipse.mylyn.docs.intent.mapping.Report Report} can't be created
*/
protected void updateEObjectLocation(Resource oldResource, Comparison comparison,
IEObjectLocation eObjectlocation, boolean useSaveURIFragment) throws Exception {
final EObject oldObject;
if (useSaveURIFragment) {
oldObject = oldResource.getEObject(eObjectlocation.getSavedURIFragment());
} else {
oldObject = oldResource.getEObject(eObjectlocation.getURIFragment());
}
final Match match = comparison.getMatch(oldObject);
if (match.getRight() != null) {
final String newURIFragment = match.getRight().eResource().getURIFragment(match.getRight());
if (!match.getDifferences().isEmpty()) {
final EObject newObject = match.getRight();
if (eObjectlocation.getFeatureName() == null) {
MappingUtils.markAsChanged(eObjectlocation, getMatchMessage(oldObject, newObject,
match));
} else {
updateLoccationSetting(comparison, eObjectlocation, oldObject, newObject, match);
}
}
eObjectlocation.setURIFragment(newURIFragment);
} else {
MappingUtils.markAsDeletedOrDelete(eObjectlocation, String.format(
"%s at %s has been deleted.", getValueString(oldObject), eObjectlocation
.getURIFragment()));
}
}
示例3: getNewValueInManySetting
import org.eclipse.emf.compare.Comparison; //导入方法依赖的package包/类
/**
* Gets the new value for a multi-valuated setting.
*
* @param comparison
* the {@link Comparison}
* @param oldValue
* the old value
* @return the new value for a multi-valuated setting
*/
protected Object getNewValueInManySetting(Comparison comparison, final Object oldValue) {
final Object newValue;
if (oldValue instanceof EObject) {
final Match valueMatch = comparison.getMatch((EObject)oldValue);
if (valueMatch != null) {
newValue = valueMatch.getRight();
} else {
newValue = oldValue;
}
} else {
newValue = oldValue;
}
return newValue;
}
示例4: findMatchingObject
import org.eclipse.emf.compare.Comparison; //导入方法依赖的package包/类
@Override
public EObject findMatchingObject(final EObject model, final EObject object) {
Resource _eResource = model.eResource();
Resource _eResource_1 = object.eResource();
final DefaultComparisonScope scope = new DefaultComparisonScope(_eResource, _eResource_1, null);
EMFCompare.Builder _builder = EMFCompare.builder();
EMFCompare _build = _builder.build();
final Comparison comparison = _build.compare(scope);
Match _match = comparison.getMatch(object);
return _match.getLeft();
}
示例5: replaceModelElementWithMatchingOne
import org.eclipse.emf.compare.Comparison; //导入方法依赖的package包/类
private static void replaceModelElementWithMatchingOne(EValue value, Comparison comparison) {
EObject originalModelElement = value.getModelElement();
Match valueMatch = comparison.getMatch(originalModelElement);
if (valueMatch == null) {
return;
}
EObject newModelElement = valueMatch.getLeft() == originalModelElement ? valueMatch.getRight()
: valueMatch.getLeft();
value.setModelElement(newModelElement);
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:11,代码来源:TraceRecordTransformationTestBase.java