This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 242521 - Autocomplete to override equals() should fill in the same code as it does via "Generate missing equals(Object)" hint or Insert Code...
Summary: Autocomplete to override equals() should fill in the same code as it does via...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-03 18:46 UTC by swpalmer
Modified: 2014-03-03 18:49 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description swpalmer 2014-03-03 18:46:45 UTC
Product Version = NetBeans IDE 8.0 RC1 (Build 201402202300)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.8.0
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.0-b69

Same goes for hashCode.

If you implement hashCode() without implementing equals(Object) a hint appears to generate the missing equals(Obect) method.  It then inserts a method that compares class member variables.  Similarly if you implement equals(Object) without implementing hashCode() there is a hint that will insert an appropriate hashCode() method for you.

I always end up using auto-complete and selecting "equals(Object obj) - override"  which inserts a useless equals method.  I then end up doing the same to insert a hashCode()method just so I can delete the equals method and have a proper one generated.  Since NB knows how to generate reasonable methods for both of these, it makes sense to just do so when I first decide that I want to.  I shouldn't have to dig around in the UI to find a different way to create these  (Source -> Insert Code... which doesn't have a default hot key)  so that NB gets it right the first time.
Comment 1 swpalmer 2014-03-03 18:49:16 UTC
Perhaps the auto-complete action should offer both an "override" and a "generate" option for those methods that it knows how to generate?