Xor the hashcode of the inherited fields (from super. Hashcode() ) and the hsshcode of the new fields.
Get Outlook for Android<https://aka.ms/ghei36> ________________________________ From: Owen Thomas <owen.paul.tho...@gmail.com> Sent: Sunday, April 19, 2020 9:34:41 AM To: Emilian Bold <emilian.b...@gmail.com> Cc: NetBeans Mailing List <users@netbeans.apache.org> Subject: Re: Overriding equals and hashCode in subclass: wizard doesn't include inherited fields. I don't know how calls to hashCode can be chained. Is there anything that can do that? I can implement hashCode in final classes using Objects.hash(), but I suppose it would be niche to be able to progressively build a hash code. On Sun, 19 Apr 2020 at 17:09, Emilian Bold <emilian.b...@gmail.com<mailto:emilian.b...@gmail.com>> wrote: Interesting. Another idea might be to rely on super.hashCode and super.equals somewhere in there? --emi On Sun, Apr 19, 2020 at 6:00 AM Owen Thomas <owen.paul.tho...@gmail.com<mailto:owen.paul.tho...@gmail.com>> wrote: Hi. I'm using NB 11.0. I'm trying to override equals and hashCode for a subclass of a type that extends object. The inherited class and the subclass both declare fields and getters for them. It seems unfortunate to me that the NB wizard that one usually uses to generate the code for equals and hashCode does not permit inherited fields (or their getters, preferably, so the fields can remain private) to be used. Have others found this to be a bit of a frustration? Owen. -- I'll cut your code at an intensity and from a place of my own choosing. Clique Space(TM). Anima ex machina. -- I'll cut your code at an intensity and from a place of my own choosing. Clique Space(TM). Anima ex machina. Terms & Conditions<http://www.riskdecisions.com/risk-decisions-terms-and-conditions> Unsubscribe<https://riskdecisions.us16.list-manage.com/unsubscribe?u=e2d6b14eee9707f9d08914b88&id=494a0816dd> to stop receiving communications from Risk Decisions