How to exclude property from Lombok builder? How to exclude property from Lombok builder? java java

How to exclude property from Lombok builder?


Yes, you can place @Builder on a constructor or static (factory) method, containing just the fields you want.

Disclosure: I am a Lombok developer.


Alternatively, I found out that marking a field as final, static or static final instructs @Builder to ignore this field.

@Builderpublic class MyClass {   private String myField;   private final String excludeThisField = "bar";}

Lombok 1.16.10


Create the builder in code and add a private setter for your property.

@BuilderXYZClientWrapper{    String name;    String domain;    XYZClient client;    public static class XYZClientWrapperBuilder {        private XYZClientWrapperBuilder client(XYZClient client) { return this; }    }}