Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Ordered property not taken into account for equality checks ?
Ordered property not taken into account for equality checks ? [message #755090] Mon, 07 November 2011 11:09 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
I my model I have a containement relation between two EClasses with the upper bound set to -1 (so Class1 contains a list of Class2). I have set the "Ordered" property on this relation to "false" but apparently this is not taken into account when checking if the lists are equals.

Here is the code that checks for the equality of the lists (taken from the EqualityHelper class):
    public boolean equals(List<EObject> list1, List<EObject> list2)
    {
      int size = list1.size();
      if (size != list2.size())
      {
        return false;
      }

      for (int i = 0; i < size; i++)
      {
        EObject eObject1 = list1.get(i);
        EObject eObject2 = list2.get(i);
        if (!equals(eObject1, eObject2))
        {
          return false;
        }
      }

      return true;
    }


Is this a bug or did I misunderstood the meaning of the "ordered" property ?
Re: Ordered property not taken into account for equality checks ? [message #755174 is a reply to message #755090] Mon, 07 November 2011 15:35 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Cedric,<br>
<br>
Comments below.<br>
<br>
On 07/11/2011 12:09 PM, Cedric Moonen wrote:
<blockquote cite="mid:j98dgl$vkm$1@news.eclipse.org" type="cite">I
my model I have a containement relation between two EClasses with
the upper bound set to -1 (so Class1 contains a list of Class2). I
have set the "Ordered" property on this relation to "false" but
apparently this is not taken into account when checking if the
lists are equals.
<br>
</blockquote>
No, because equality for lists is defined by Java, so order must
always be respected.<br>
<blockquote cite="mid:j98dgl$vkm$1@news.eclipse.org" type="cite">
<br>
Here is the code that checks for the equality of the lists (taken
from the EqualityHelper class):
<br>
   public boolean equals(List&lt;EObject&gt; list1,
List&lt;EObject&gt; list2)
<br>
   {
<br>
     int size = list1.size();
<br>
     if (size != list2.size())
<br>
     {
<br>
       return false;
<br>
     }
<br>
<br>
     for (int i = 0; i &lt; size; i++)
<br>
     {
<br>
       EObject eObject1 = list1.get(i);
<br>
       EObject eObject2 = list2.get(i);
<br>
       if (!equals(eObject1, eObject2))
<br>
       {
<br>
         return false;
<br>
       }
<br>
     }
<br>
<br>
     return true;
<br>
   }
<br>
<br>
<br>
Is this a bug or did I misunderstood the meaning of the "ordered"
property ?
<br>
</blockquote>
Order is actually kind of useless because we've not implemented any
support for it:<a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=75931"><br>
</a>
<blockquote><a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=75931">https://bugs.eclipse.org/bugs/show_bug.cgi?id=75931</a><br>
</blockquote>
It's more of a vestigial remnant from MOF.<br>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[EMF Compare] Path must include project and resource name
Next Topic:Change class of a given EObject
Goto Forum:
  


Current Time: Thu Apr 25 17:30:13 GMT 2024

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

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

Back to the top