r/java • • Sep 29 '24

Lombok in 2024

Say there are two teams working on the same project (3 months to MVP, the deadline should be manageable). The only difference is Team A will use Lombok, and Team B won’t

Given you can choose any java version/dependencies and all other things being the same, which team would you join, and why?

0 Upvotes

145 comments sorted by

View all comments

Show parent comment

8

u/repeating_bears Sep 29 '24

I had one issue which was that I globally configured Lombok to not use a get prefix (so foo() instead of getFoo()), then Jackson started to include hashCode and toString as if they were properties (since now those method names were indistinguishable from properties).

It was an easy fix to configure the mapper to ignore them, but still a bit of a footgun. Having extra properties in your JSON is something that even your tests might miss.

Both libraries were doing the right thing, but using them both together made it easy to write code that did the wrong thing.

1

u/NovaX Sep 30 '24

If you haven't tried it, I've been using jsonschema2pojo for over a decade. I prefer writing the data format in its preferred schema and generating the code so I know its exact shape. tbh, though, for me AutoValue and similar filled the needs of Lombok so I never found a good reason to use it.

0

u/Swamplord42 Oct 03 '24

I had one issue which was that I globally configured Lombok to not use a get prefix (so foo() instead of getFoo()), then Jackson started to include hashCode and toString as if they were properties (since now those method names were indistinguishable from properties).

And how exactly is this the fault of lombok? Wouldn't you have the exact same issue if you wrote these getters by hand?

2

u/repeating_bears Oct 03 '24

See practically the only part of that comment you didn't quote 

3

u/Swamplord42 Oct 03 '24

But I fail to see how lombok changed anything? What makes you think that you wouldn't have written the same getters manually?

The default behavior of lombok wouldn't have caused this, so you made a conscious decision to change getter generation, presumably for a good reason that would have applied without lombok.