|
|
Re: [XCORE] How to define equality? [message #1263862 is a reply to message #1263849] |
Tue, 04 March 2014 20:58 |
|
Hi, Roger,
Much of the EMF run-time assumes (read: requires) that implementations
of the EObject interface do not override equals() and hashCode(). That
is, it is required that they inherit equality-is-identity semantics
from java.lang.Object. The EMF run-time generally tests == instead of
equals(), but perhaps not consistently, and makes extensive use of
maps, so you can expect stuff not to work in surprising ways.
If you need to test EObjects for structural equality, it is best to use
EcoreUtil.equals(...) externally, not overriding Object::equals().
Cheers,
Christian
On 2014-03-04 20:45:19 +0000, Roger Gilliar said:
> The following does work:
>
> op boolean equals(Object object) {
> if (object instanceof EObject) {
> EcoreUtil.equals(this, object)
> } else {
> false
> }
> }
|
|
|
|
Powered by
FUDForum. Page generated in 0.03951 seconds