core-java
core-java copied to clipboard
Unify the API of hand-written `Builder`s
The framework uses the Builder pattern to create complex Java objects such as Delivery
.
However, the naming of getters and setters varies from time to time. We need to review the code throughout the repository and unify the naming approach.
The proposal is as follows.
FooBar.Builder builder = FooBar.newBuilder();
builder
.setTheExpectation(myExpectation); // setter naming
// Check whether the value has been set.
if(builder.hasTheExpectation()) {
// Throws NPE if not set.
TheExpectation justSet = builder.getTheExpectation();
}
We could then automate the Builder
testing using Java reflection.