Created
December 5, 2024 17:33
-
-
Save borodicht/70f4b8b6e4ea78219c624547b128a3ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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