If I have the following setup:
public enum VehicleType {
CAR, BUS, TRUCK;
}
@ToString
@EqualsAndHashCode
@Getter
@SuperBuilder(toBuilder = true)
public abstract class Vehicle {
private VehicleType type;
private String make;
private String model;
}
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Getter
@SuperBuilder(toBuilder = true)
public class Car extends Vehicle {
// how do I force the "type" to be "CAR"
}
In this case, how can I force the subclass to have a specific value for type
field. Without Lombok, I could set the type
to CAR
in the constructor itself but how can I achieve the same thing with builders?