Created
April 5, 2019 07:40
-
-
Save akshanshjain95/8d38e92a3601b13aa04e74f66cfafc03 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 final String middleName; | |
private final String facebookId; | |
private final String twitterId; | |
public static class Builder { | |
private final String firstName; | |
private final String lastName; | |
private String middleName = ""; | |
private String facebookId = ""; | |
private String twitterId = ""; | |
public Builder(String firstName, String lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
public Builder middleName(String middleName) { | |
this.middleName = middleName; | |
return this; | |
} | |
public Builder facebookId(String facebookId) { | |
this.facebookId = facebookId; | |
return this; | |
} | |
public Builder twitterId(String twitterId) { | |
this.twitterId = twitterId; | |
return this; | |
} | |
public Person build() { | |
return new Person(this); | |
} | |
} | |
private Person(Builder builder) { | |
this.firstName = builder.firstName; | |
this.lastName = builder.lastName; | |
this.middleName = builder.middleName; | |
this.facebookId = builder.facebookId; | |
this.twitterId = builder.twitterId; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment