Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Keep original lombok builder setter and overload

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading