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
| AddressBuilder builder = new AddressBuilder(); | |
| builder.setStreet(...); | |
| builder.setStreetNumer(...); | |
| builder.setZipCode(...); | |
| builder.setCity(...); | |
| builder.setState(...); | |
| builder.setCountry(...); | |
| Address address = builder.build(); |
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
| Address address = new AddressBuilder() | |
| .setStreet(...) | |
| .setStreetNumer(...) | |
| .setZipCode(...) | |
| .setCity(...) | |
| .setState(...) | |
| .setCountry(...) | |
| .build(); |
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
| Address address = new AddressBuilder() | |
| .forStreetNumber(...).ofStreet(...) | |
| .inCity(...).withZipCode(...) | |
| .lyingInState(...).ofCountry(...) | |
| .build(); |
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 static AddressBuilder newAddress() { | |
| return new AddressBuilder(); | |
| } | |
| } |
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
| Address address = newAddress() | |
| .forStreetNumber(...).ofStreet(...) | |
| .inCity(...).withZipCode(...) | |
| .lyingInState(...).ofCountry(...) | |
| .build(); |
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 Address { | |
| private String street; | |
| ... | |
| public Address(AddressBuilder builder) { | |
| street = validateStreet(builder.getStreet()); | |
| ... | |
| } | |
| ... | |
| } |
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; | |
| } | |
| } |
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 Address { | |
| public static Builder newAddress() { | |
| return new Address().new Builder(); | |
| } | |
| private String street; | |
| ... | |
| public class Builder { | |
| public Builder ofStreet(String initialStreet) { | |
| street = validateStreet(initialStreet); | |
| return this; |
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
| @Named("address") | |
| @ConversationScoped | |
| public class AddressBuilder { | |
| ... | |
| } |
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
| class FluentELResolver extends BeanELResolver { | |
| public boolean isReadOnly(ELContext context, Object base, Object property) { | |
| return getFluentMethod(context, base, property.toString()) != null; | |
| } | |
| public void setValue(ELContext context, Object base, Object property, Object value) { | |
| invoke(getFluentMethod(context, base, property.toString), base, value); | |
| } |