Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 486410

Summary: Change hashCode() and equals() implementation of Node
Product: [Tools] GEF Reporter: Arne Adams <arne.adams>
Component: GEF GraphAssignee: gef-inbox <gef-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: nyssen
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Arne Adams CLA 2016-01-23 05:29:25 EST
the current implementation of the hash code of a Node uses the attributes map.
This breaks the following use case:
- create a node
- store it in a local hashset
- add it to the graph
- in createVisual change css attributes of the created node.

After that the node won't be found in the hashset any more.

Proposal for a fix:
use (only) the node id (ZestProperties.ELEMENT_CSS_ID) for the hashcode
Comment 1 Alexander Nyßen CLA 2016-01-23 08:42:57 EST
The equals() implementation would have to be adjusted as well to satisfy your use case.

As Node should be unaware of ZestProperties this is not going to work. We would either have to fall back to Object equality (i.e. not overwrite hashCode() and equals() at all), or point out a specific attribute (or a set of attributes) that is used to determine equality.
Comment 2 Arne Adams CLA 2016-01-23 10:08:19 EST
I see your point - I'll use a hashmap from id to node for my use case
Comment 3 Alexander Nyßen CLA 2016-01-26 11:34:04 EST
(In reply to Arne Adams from comment #2)
> I see your point - I'll use a hashmap from id to node for my use case

OK, resolving this as WONTFIX then.