Strange generated hashCode() ?
Hi,
When you press alt-insert, and choose hashCode(), the default[1]
template first calls super.hashCode().
I think it's a problem when the super class is Object!
If the hashCode depends on Object.hashCode() implementation then two
hashCodes will be different even if the objects have the same attribute
values.
Does anybody else think it's a problem?
Thanks
BoD
by the way, is there a way to change the template?
Please sign in to leave a comment.
BoD wrote:
Yep, that's a problem but I haven't observed this behavior in the latest Irida
builds. For classes that are directly derived from Object IDEA doesn't insert
a super.hashCode() into the code. Which build/version are you referring to?
No, there's not. However, there's the ToString-plugin that can generate code based
on user-defined templates. There's also a request you could vote for:
http://www.jetbrains.net/jira/browse/IDEABKL-2880
HTH,
Sascha
My mistake. It works as you say if the object is directly derived from
Object.
I voted for this request.
BoD
Sascha Weinreuter wrote:
>>If the hashCode depends on Object.hashCode() implementation then two
>>hashCodes will be different even if the objects have the same attribute
>>values.
>>[1] by the way, is there a way to change the template?
Actually the rule is that it will/should only add super.hashCode() if your class
is derived from a class that overrides hashCode().
Sascha
Sascha Weinreuter wrote:
>>My mistake. It works as you say if the object is directly derived from Object.
>>I voted for this request.
That is a good rule, unless some (stupid) class overrides hashCode with
return super.hashCode();
:)
BoD