Skip to main content



      Home
Home » Modeling » Compare » Set equality helper
Set equality helper [message #1181133] Mon, 11 November 2013 06:47 Go to next message
Eclipse UserFriend
I have this case:

EObject leftChild = left.getChild();
EObject rightChild = right.getChild();

Both left and right have the same EClass and are EObjects at different times, i.e. left.getTimestamp() < right.getTimestamp().

leftChild should be the same as rightChild as their URI is the same, but they are different Java object instances, so are marked as ReferenceChange diffs when doing the comparison.

How do I tell EMF Compare to compare the URI instead of using equals (as is normal for EObjects)? I guess this is done by an IEqualityHelper, but where do I set it?

Thanks!
Re: Set equality helper [message #1185709 is a reply to message #1181133] Thu, 14 November 2013 03:02 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

We have an example of how to alter the equality helper in the 'Custom data types' FAQ entry.

Please let us know if this does not help Smile.

Laurent Goubet
Obeo
Re: Set equality helper [message #1194221 is a reply to message #1185709] Mon, 18 November 2013 06:54 Go to previous messageGo to next message
Eclipse UserFriend
Laurent,
I should have mentioned that I am using sources from Git head.
There is no Builder.setMatchEngine().

Laurent Goubet wrote on Thu, 14 November 2013 09:02
Hi,

We have an example of how to alter the equality helper in the 'Custom data types' FAQ entry.

Please let us know if this does not help Smile.

Laurent Goubet
Obeo

Re: Set equality helper [message #1196098 is a reply to message #1194221] Tue, 19 November 2013 03:43 Go to previous message
Eclipse UserFriend
Indeed, we forgot to update this example when we changed that API. The means are still the same : you need to change the equality helper. However changing the equality helper should now be done through a factory. We'll update the FAQ example, for now you should be able to build from this other example; what you need to alter in this one is the "DefaultEqualityHelperFactory" : you'll need your own sub-class of that.

Basically, something of the sort:

IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory() {
    public IEqualityHelper createEqualityHelper() {
        return new MyEqualityHelper();
    }
});
IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE);
IMatchEngine customMatchEngine = new DefaultMatchEngine(matcher, comparisonFactory);

IMatchEngine.Factory engineFactory = new MatchEngineFactoryImpl() {
  public IMatchEngine getMatchEngine() {
    return customMatchEngine;
  }
};
engineFactory.setRanking(20); // default engine ranking is 10, must be higher to override.
registry.add(engineFactory);
EMFCompare.builder().setMatchEngineFactoryRegistry(registry).build().compare(scope);


Laurent Goubet
Obeo
Previous Topic:Single-Side Match and location of ADD Diff
Next Topic:How to open a compare editor with a comparison object
Goto Forum:
  


Current Time: Wed Jul 23 15:26:43 EDT 2025

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

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

Back to the top