Home > Mobile >  Keep original lombok builder setter and overload
Keep original lombok builder setter and overload

Time:07-19

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?

CodePudding user response:

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

  • Related