Copy the code from https://stackoverflow.com/questions/44948858/lombok-builder-on-a-class-that-extends-another-class. `` `@ Builder``` is often attached to the class, but there is a workaround to give it to the constructor and enumerate both parent and child parameters there.
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.20</version>
</dependency>
@AllArgsConstructor
@ToString
public class Parent {
	  private double d;
	  private float e;
}
@ToString(callSuper=true)
public class Child extends Parent  {
	  private String a;
	  private int b;
	  private boolean c;
	  @Builder
	  public Child(String a, int b, boolean c, double d, float e) {
	    super(d, e);
	    this.a = a;
	    this.b = b;
	    this.c = c;
	  }
}
Child child = Child.builder().a("aVal").b(1000).c(true).d(10.1).e(20.0F).build();
System.out.println(child);
Child(super=Parent(d=10.1, e=20.0), a=aVal, b=1000, c=true)
        Recommended Posts