Created
April 19, 2018 11:25
-
-
Save jandk/412fa24ed0a869de6fc1016df39377a3 to your computer and use it in GitHub Desktop.
This file contains 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
public final class Person { | |
private final String firstName; | |
private final String lastName; | |
private Person(String firstName, String lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
public String getFirstName() { | |
return firstName; | |
} | |
public String getLastName() { | |
return lastName; | |
} | |
public static Builder builder() { | |
return new Builder(); | |
} | |
public static final class Builder { | |
private String firstName; | |
private String lastName; | |
private Builder() { | |
} | |
public Builder firstName(String firstName) { | |
this.firstName = firstName; | |
return this; | |
} | |
public Builder lastName(String lastName) { | |
this.lastName = lastName; | |
return this; | |
} | |
public Person build() { | |
return new Person(firstName, lastName); | |
} | |
} | |
} |
Author
jandk
commented
Apr 19, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment