Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PersonBuilder {
- public static FirstNameStep newBuilder() {
- return new Steps();
- }
- private PersonBuilder() {
- }
- public static interface FirstNameStep {
- LastNameStep firstName(String string);
- }
- public static interface LastNameStep {
- RemainingSteps lastName(String value);
- }
- public static interface RemainingSteps {
- Person build();
- RemainingSteps dateOfBirth(Date date);
- }
- private static class Steps implements FirstNameStep, LastNameStep, RemainingSteps {
- private String firstName;
- private String lastName;
- private Date dateOfBirth;
- public LastNameStep firstName(String value) {
- this.firstName = value;
- return this;
- }
- public RemainingSteps lastName(String value) {
- this.lastName = value;
- return this;
- }
- public RemainingSteps dateOfBirth(Date value) {
- this.dateOfBirth = value;
- return this;
- }
- public Person build() {
- return new Person(firstName, lastName, dateOfBirth);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment