You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be cool if Lombok could make up for the inability to extend records in Java by generating a composite record from another record you specify.
Plain Java:
record Vehicle(int topSpeed, int passengers) {
}
record Bike(int topSpeed, int passengers, int wheels) {
public Bike(Vehicle vehicle, int wheels) {
this(vehicle.topSpeed(), vehicle.passengers(), wheels);
}
}
Lombok:
@ExtendsRecord(Vehicle.class) // generates the Bike record above
record Bike(int wheels) {
}
// can create specifying all fields
Bike bike = new Bike(50, 1, 2);
// or by passing in a "base" record along with the extra parameters
Vehicle twoSeater = new Vehicle(50, 2);
Bike tandem = new Bike(twoSeater, 2);
The text was updated successfully, but these errors were encountered:
It would be cool if Lombok could make up for the inability to extend records in Java by generating a composite record from another record you specify.
Plain Java:
Lombok:
The text was updated successfully, but these errors were encountered: