Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Compare] How to customize EMF compare mechanism - Match Phase?
[Compare] How to customize EMF compare mechanism - Match Phase? [message #1412103] Mon, 25 August 2014 09:54
Bhushan Patil is currently offline Bhushan PatilFriend
Messages: 10
Registered: February 2014
Junior Member

I want to customize EMF Compare mechanism.
My requirement is - Objects should be matched through their name only and should not use default logic (which is provided by EMF compare to match resources).

As per developer guide we can do this by following code:

Function<EObject, String> idFunction === new Function<EObject, String>() {
public String apply(EObject input) {
if (input instanceof MyEObject) {
return ((MyEObject)input).getName();
// a null return here tells the match engine to fall back to the other matchers
return null;
// Using this matcher as fall back, EMF Compare will still search for XMI IDs on EObjects
// for which we had no custom id function.
IEObjectMatcher fallBackMatcher === DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE);
IEObjectMatcher customIDMatcher === new IdentifierEObjectMatcher(fallBackMatcher, idFunction);

IComparisonFactory comparisonFactory === new DefaultComparisonFactory(new DefaultEqualityHelperFactory());

IMatchEngine matchEngine === new DefaultMatchEngine(customIDMatcher, comparisonFactory);
IMatchEngine.Factory.Registry registry === MatchEngineFactoryRegistryImpl.createStandaloneInstance();
// for OSGi (IDE, RCP) usage
// IMatchEngine.Factory.Registry registry === EMFCompareRCPPlugin.getMatchEngineFactoryRegistry();
engineFactory.setRanking(20); // default engine ranking is 10, must be higher to override.

My questions are -

1) How can I plug this code in existing EMF compare mechanism?
2) Do I need to create separate menu same as (Compare with -> Each Other) and invoke this code using the menu?
3) Is it possible to plug this code using extension points?
4) If possible then what are those extension points?

Please suggest.
Previous Topic:EAnnotation#getContents() and Ecore editor
Next Topic:[CDO] Low performance of CDOResource.getURI()
Goto Forum:

Current Time: Tue Jul 16 03:15:15 GMT 2024

Powered by FUDForum. Page generated in 0.03706 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top