Skip to content

Instantly share code, notes, and snippets.

@Kotlin-Native
Created July 10, 2015 07:01
Show Gist options
  • Select an option

  • Save Kotlin-Native/da76efaca64e1c795fec to your computer and use it in GitHub Desktop.

Select an option

Save Kotlin-Native/da76efaca64e1c795fec to your computer and use it in GitHub Desktop.
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