I'm completely confused how Lombok is supposed to be used in the following scenario:
Base class:
@Data
public abstract class BaseClass {
protected final String foo;
protected final String bar;
}
Subclass:
@Data
public class SubClass extends BaseClass {
private final String bazz;
}
Lombok complains about the @Data
annotation on the second class that it needs a default constructor in the base class. However, the fields in the base class are final, so a default constructor would have to initialize all fields to some value, which is messy, since they can't then be changed by the constructor of the sub class.
What is the correct way to set up these classes such that the concrete subclass can be created via a constructor with arguments? Can a builder be used with the final fields? I would like to avoid writing code as much as possible and rely on Lombok annotations (although I am aware this may not be possible).