Skip to main content



      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 09:20 Go to next message
Eclipse UserFriend
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
Re: EcoreUtil.equals is not returning the value properly [message #1699338 is a reply to message #1699335] Tue, 23 June 2015 09:31 Go to previous messageGo to next message
Eclipse UserFriend
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 :)
icon5.gif  Re: EcoreUtil.equals is not returning the value properly [message #1699340 is a reply to message #1699338] Tue, 23 June 2015 09:37 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: EcoreUtil.equals is not returning the value properly [message #1699344 is a reply to message #1699340] Tue, 23 June 2015 09:46 Go to previous messageGo to next message
Eclipse UserFriend
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
icon14.gif  Re: EcoreUtil.equals is not returning the value properly [message #1699351 is a reply to message #1699344] Tue, 23 June 2015 10:07 Go to previous message
Eclipse UserFriend
Hi Ed,

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


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


Current Time: Sun Jul 06 21:44:15 EDT 2025

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

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

Back to the top