Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.clients.erp;
- public class Employee {
- private final int id;
- private final String ssn, lastName, firstName;
- private final String address1, address2, city, state, zip, phone1, phone2;
- public static class Builder {
- private final int id;
- private final String ssn;
- private final String lastName;
- private final String firstName;
- private String address1 = null;
- private String address2 = null;
- private String city = null;
- private String state = null;
- private String zip = null;
- private String phone1 = null;
- private String phone2 = null;
- // required parameters
- public Builder(int id, String ssn, String lastName, String firstName) {
- this.id = id;
- this.ssn = ssn;
- this.lastName = lastName;
- this.firstName = firstName;
- }
- // optional parameters
- public Builder address1 (String val) { address1 = val; return this; }
- public Builder address2 (String val) { address2 = val; return this; }
- public Builder city (String val) { city = val; return this; }
- public Builder state (String val) { state = val; return this; }
- public Builder zip (String val) { zip = val; return this; }
- public Builder phone1 (String val) { phone1 = val; return this; }
- public Builder phone2 (String val) { phone2 = val; return this; }
- public Employee build() {
- return new Employee(this);
- }
- }
- private Employee(Builder builder) {
- id = builder.id;
- ssn = builder.ssn;
- lastName = builder.lastName;
- firstName = builder.firstName;
- address1 = builder.address1;
- address2 = builder.address2;
- city = builder.city;
- state = builder.state;
- zip = builder.zip;
- phone1 = builder.phone1;
- phone2 = builder.phone2;
- }
- @Override
- public String toString() {
- return "Employee [id=" + id + ", ssn=" + ssn + ", lastName=" + lastName + ", firstName=" + firstName
- + ", address1=" + address1 + ", address2=" + address2 + ", city=" + city + ", state=" + state
- + ", zip=" + zip + ", phone1=" + phone1 + ", phone2=" + phone2 + "]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement