Skip to content
Advertisement

Inheritance for builders in lombok

I was trying to use lombok for my project.

I have a class A:

JavaScript

and a class B:

JavaScript

I am getting an error saying builder() in B cannot override builder() in A, as return type in BBuilder is not compatible with return type in ABuilder.

Is there some way to do this using lombok? I do not want to write the complete builder for for B, unless I don’t have any other option.

PS: I have given explicit constructor for class B due to Issue. I tried searching, but I could not find a good solution for the same.

Advertisement

Answer

Here we just need to call super of the builder.

JavaScript
Advertisement