@Setter - return this in set methods

Skip to first unread message

Frank Gamarra

Jul 19, 2022, 11:17:11 AMJul 19
to Project Lombok

what do you think?

Reinier Zwitserloot

Sep 6, 2022, 10:18:48 AMSep 6
to Project Lombok
I'm not sure how to take your question.

Perhaps you meant: I would like to do this.

Then, good news! Lombok already does. But you have to opt into this behaviour via a lombok.config key. Read the docs of `@Setter`, which explains all this.

Perhaps you meant: This should be the default

Request denied. Explanation: Various tools reflectively look for setters and many of those just do not consider any method that doesn't return void. Probably because of a pseudo-spec (in that it is incomplete, not official, and multiple conflicting versions exist) called 'the bean spec'. While conflicts exist, they all either state that setters must return void, or don't mention anything about return types.

Furthermore if we change this now, we ruin hundreds of thousands of people's days as all their code would break. Even if there was no good reason not to do it, that, alone, would suffice.

On Tuesday, July 19, 2022 at 5:17:11 PM UTC+2 Frank Gamarra wrote:

what do you think?
Reply all
Reply to author
0 new messages