We are using Grpc with our java apps and we have a nested object defined in protobuff.
example of the proto:
message Person {
string name = 1;
Child child = 2;
}
message Child {
string name = 1;
Hobby hobbies = 2;
}
message Hobby {
string name = 1;
string reason = 2;
}
When I want to update the reason for the child's hobby I have to do something like:
person.toBuilder()
.setChild(
person.getChild.toBuilder()
.setHobby(
person.getChild().getHobby().toBuilder()
.setReason("new reason")
.build()
)
.build()
)
.build()
The code above is not the nicest and my question is if there is any better way to accomplish the same?