Skip to content

Instantly share code, notes, and snippets.

@akshanshjain95
Created April 5, 2019 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akshanshjain95/8d38e92a3601b13aa04e74f66cfafc03 to your computer and use it in GitHub Desktop.
Save akshanshjain95/8d38e92a3601b13aa04e74f66cfafc03 to your computer and use it in GitHub Desktop.
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