【错误警告】Generating equals/hashCode implementation but without a call to superclass

【错误警告】Generating equals/hashCode implementation but without a call to superclass


You should also pay attention to small problems and try to fix them as much as possible to avoid errors caused by Murphy's Law.

question:

Generating equals/hashCode implementation but without a call to
superclass, even though this class does not extend java.lang.Object.
If this is intentional, add ‘(callSuper=false)’ to your type.

translate:

Generates an equals/hashCode implementation, but does not call the superclass even though this class does not extend java.lang.Object. If this is intentional, add "(callSuper = false)" to your type.

Solution:

Add the @EqualsAndHashCode(callSuper = true) annotation to the class.
After adding it, you can include the attributes of its parent class when generating the equals/hashCode method.

If there are any mistakes, please let me know!
When reprinting or quoting the content of this article, please indicate the source and original author: Juzu Qingzhong;

Guess you like

Origin blog.csdn.net/weixin_44510587/article/details/131113251