Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep original lombok builder setter and overload

Tags:

java

lombok

I'm making a Builder using lombok but have noticed that if I overload a setter, it stops generating the original.

In example below, there's no setter for NamedIdentity player anymore. In my case, I want both the original and the overload. I don't see any documentation that forces the original so I see only two options:

  • Manually add the missing setter myself
  • Name the second setter differently
public class Activity {

    @Builder()
    public Activity(NamedIdentity player) {}


    public static class ActivityBuilder {

        public ActivityBuilder player(UUID uuid, String name) {
            this.player = new NamedIdentity(uuid, name));
            return this;
        }
    }
}

Is there another way to accomplish this?

like image 837
helion3 Avatar asked Oct 24 '25 15:10

helion3


1 Answers

You can make Lombok ignore existing methods by annotating them with @Tolerate.

like image 132
Jan Rieke Avatar answered Oct 26 '25 05:10

Jan Rieke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!