Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Ecoreutil.copier(Resulting hashcodes of the copied EObject is different from original EObject)
Ecoreutil.copier [message #1786825] Sun, 13 May 2018 14:33 Go to next message
Manoj Keshavaprakash is currently offline Manoj KeshavaprakashFriend
Messages: 4
Registered: October 2017
Junior Member
Hi,

I am using ECoreUtil.copier to create a copy of my EObject. However, the exact copy is created but with different hashcodes. Could anyone explain me why does the hashcodes change.

Regards,
Manoj
Re: Ecoreutil.copier [message #1786827 is a reply to message #1786825] Sun, 13 May 2018 16:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a basic Java question. Every Java Object has a hashCode. Unless there is an override of java.lang.Object.hashCode(), it will be the default Java implementation which is an arbitrary int value that is typically (but of course not always) different for two different instances. (And you should never override equals or hashCode for an EObject implementation as documented in the Javadoc for that interface.)

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ecoreutil.copier [message #1786830 is a reply to message #1786827] Sun, 13 May 2018 16:07 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

For many/most objects the hashcode is computed from the memory address which will vary for a copy.

Regards

Ed Willink
Previous Topic:Unexpected results with EObject::eGet(..)
Next Topic:Validation on doSave()
Goto Forum:
  


Current Time: Thu Apr 25 11:18:28 GMT 2024

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

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

Back to the top