@EqualsAndHashCode, hashcode generation

88 views
Skip to first unread message

Marco Ferretti

unread,
Aug 29, 2023, 8:27:51 PM8/29/23
to Project Lombok
Hi, 
I am looking at the example "Vanilla" java for the generated code when using @EqualsAndHashCode (https://projectlombok.org/features/EqualsAndHashCode) and I have a question.

When I look at the generated code for equals I see that the method uses getters for non opted out attributes while it accesses the attribute directly when generating the hashcode method.

Is this behavior happening always (using getters for equals, attribute for hashcode) or is it somehow configurable?

My use case would be a JPA entity where I have a uuid as the only opted in attribute but the attribute is set only when read (for performance reason) thus the direct access of the attribute would return null while the access to the getter would return a correct value.

Thanks in advance for any hint !

Floris Kraak

unread,
Aug 30, 2023, 1:05:36 AM8/30/23
to project...@googlegroups.com
Delombok should be able to tell you what it generates.

Op wo 30 aug. 2023 02:27 schreef Marco Ferretti <marco.f...@axiante.com>:
--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/69017017-7b74-460c-b880-51390bf54552n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages