Created
July 10, 2015 07:01
-
-
Save Kotlin-Native/da76efaca64e1c795fec to your computer and use it in GitHub Desktop.
This file contains hidden or 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 class AddressBuilder { | |
| ... | |
| public Address build() { | |
| Address address = new Address(); | |
| address.setStreet(validateStreet(street)); | |
| ... | |
| return address; | |
| } | |
| } | |
| public class Address { | |
| ... | |
| Address() { | |
| // reduce visibility of the default constructor | |
| } | |
| public String getStreet() { | |
| return street; | |
| } | |
| // may just be used by the builder | |
| void setStreet(String initialStreet) { | |
| street = initialStreet; | |
| } | |
| ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment