Lombok @Builder workaround

Lombok @Builder does not work for cases of using inheritance:

for instance

class Foo{
 protected int xyz1;
 .....
 protected String xyz7;
}


class Bar extends Foo{

}

For this use case, Lombok will not be able to generate methods to set the value of the parameter defined in the Foo class.

Workaround for this:

  • Manual creation of a panel constructor.
  • Place annotation Builder to this constructor.

Is there a better workaround?

+4
source share
1 answer

This is a little hidden, but people used to ask this question, see:

https://reinhard.codes/2015/09/16/lomboks-builder-annotation-and-inheritance/

+3
source

All Articles