-
Notifications
You must be signed in to change notification settings - Fork 99
Open
Description
As I convert more and more (Java) code from Apache Thrift to Thrifty, I've started to run into a pattern where I start with an existing struct object that might be null and then "extends" that struct by setting some existing values. The most direct way to do this is by conditionally calling the correct Builder constructor:
public Struct updateStruct(Struct struct) {
Struct.Builder builder = (struct == null)
? new Struct.Builder()
: new Struct.Builder(struct);
builder.foo(True);
return builder.build();
}It would be much more convenient if Struct.Builder accepted a nullable argument and added a if (struct != null) guard to the generated code so the above could just become:
public Struct updateStruct(Struct struct) {
return new Struct.Builder(struct)
.foo(True)
.build();
}That would detract a bit from the purity of the existing Builder interface, but this could be a case where caller convenience could take precedence.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels