Databases Reference
In-Depth Information
}
public Builder phoneNumber(String phoneNumber) {
built.phoneNumber = phoneNumber;
return this;
}
public Contact build() {
return built;
}
}
}
We have to also add a static getBuilder() method to the Contact class. Our
implementation is pretty straightforward. We create a new Contact.Builder object
and return the created object. The source code of this method is given as follows:
public static Builder getBuilder(String firstName, String lastName) {
return new Builder(firstName, lastName);
}
Updating contact information
The Contact class has two methods that we can use to update contact
information: the update() method that updates the contact information and the
updateAddress() method that updates the address information of the contact. The
source code of these methods is given as follows:
public void update(final String firstName, final String lastName,
final String emailAddress, final String phoneNumber) {
this.firstName = firstName;
this.lastName = lastName;
this.emailAddress = emailAddress;
this.phoneNumber = phoneNumber;
}
public void updateAddress(final String streetAddress, final String
postCode, final String postOffice, final String state, final String
country) {
if (address == null) {
address = new Address();
}
address.update(streetAddress, postCode, postOffice, state,
country);
}
 
Search WWH ::




Custom Search