Skip to content

Instantly share code, notes, and snippets.

@borodicht
Created December 5, 2024 17:33
Show Gist options
  • Save borodicht/70f4b8b6e4ea78219c624547b128a3ea to your computer and use it in GitHub Desktop.
Save borodicht/70f4b8b6e4ea78219c624547b128a3ea to your computer and use it in GitHub Desktop.
package DTO_models;
import lombok.*;
@Data
@AllArgsConstructor
public class Car {
private final String make;
private final String model;
private Car (CarBuilder builder) {
this.make = builder.make;
this.model = builder.model;
}
public static class CarBuilder {
private String make;
private String model;
public CarBuilder setMake(String make) {
this.make = make;
return this;
}
public CarBuilder setModel(String model) {
this.model = model;
return this;
}
public Car build() {
return new Car(this);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment