Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » EcoreUtil.equals is not returning the value properly(EcoreUtil.equals is not returning the value properly)
icon5.gif  EcoreUtil.equals is not returning the value properly [message #1699335] Tue, 23 June 2015 13:20 Go to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi All,

As far as I know EcoreUtil.equals(eObj1,eObj2) checks for data equality but not references.

Say that I have an Eobject with data :

node MyNode {

description "Hello"
refers OtherNode
}

OtherNode is also an object like MyNode defined above.

I have two eobjects holding the same data for MyNode and ECoreUtil.equals works properly.


Now I have a variation.

The OtherNode doesn't exist and it gives me a couldn't resolve error in the editor.

But say that still I have defined MyNode in the same way and at this time ECoreUtil.equals returns false.

Can someone help me how can I solve this now ? Is overriding equals method is the only way ?



Thanks in advance Smile


Arshad
Re: EcoreUtil.equals is not returning the value properly [message #1699338 is a reply to message #1699335] Tue, 23 June 2015 13:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Arshad,

Comments below.


On 23/06/2015 3:20 PM, Arshad Adavani wrote:
> Hi All,
>
> As far as I know EcoreUtil.equals(eObj1,eObj2) checks for data
> equality but not references.
No, it does a deep comparison that includes navigating and comparing the
objects reachable via containment and cross references.
>
> Say that I have an Eobject with data :
>
> node MyNode {
>
> description "Hello"
> refers OtherNode }
>
> OtherNode is also an object like MyNode defined above.
>
> I have two eobjects holding the same data for MyNode and
> ECoreUtil.equals works properly.
>
>
> Now I have a variation.
>
> The OtherNode doesn't exist and it gives me a couldn't resolve error
> in the editor.
So it's a broken cross reference, i.e., one that fails to resolve.
>
> But say that still I have defined MyNode in the same way and at this
> time ECoreUtil.equals returns false.
And both instances have the same broken cross reference?
>
> Can someone help me how can I solve this now ? Is overriding equals
> method is the only way ?
If the default implementation doesn't do what you want, you'd have to
specialize it to implement your own notion of structural equality.
>
>
>
> Thanks in advance :)


Ed Merks
Professional Support: https://www.macromodeling.com/
icon5.gif  Re: EcoreUtil.equals is not returning the value properly [message #1699340 is a reply to message #1699338] Tue, 23 June 2015 13:37 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Ed,

Thanks for your reply.

Yes, both instances have the same broken cross reference.
And still it returns me false. Any idea why ?


Regards,
Arshad


Arshad
Re: EcoreUtil.equals is not returning the value properly [message #1699344 is a reply to message #1699340] Tue, 23 June 2015 13:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Arshad,

A debugger can answer this question better than I can theorize about the
extract structure of your specific test scenario.

On 23/06/2015 3:37 PM, Arshad Adavani wrote:
> Hi Ed,
>
> Thanks for your reply.
>
> Yes, both instances have the same broken cross reference.
> And still it returns me false. Any idea why ?
>
>
> Regards,
> Arshad


Ed Merks
Professional Support: https://www.macromodeling.com/
icon14.gif  Re: EcoreUtil.equals is not returning the value properly [message #1699351 is a reply to message #1699344] Tue, 23 June 2015 14:07 Go to previous message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Ed,

I resolved both the objects before comparison and after that it works quite well... Smile


Regards,
Arshad


Arshad
Previous Topic:problems with global scoping
Next Topic:Call a jar library function from generated code in src-gen
Goto Forum:
  


Current Time: Wed Sep 25 21:51:40 GMT 2024

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

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

Back to the top