My current code is cluttered with repeated
String str=x.getFoo();
if(str != null)
{
builder.setFoo(str);
}
since the setFoo method of builder throws an NPE if one is trying to set null.
How about adding additional generated setFooIfNotNull (or something briefer with the same intention) methods to the builder that contains exactly that code?
The parsing has a similar problem. It returns "" instead of null if a String has not been set.
This creates repeated
if(x.hasFoo())
{
result.setFoo(x.getFoo());
}
Perhaps methods like getFooOrNull() could solve this.
These two issues are the only ones that keep hitting me while writing encoders and decoders using Protobuf.
I keep forgetting either one or the other which only dawns on me while implementing the tests for the persistence code.
What do you think?
Regards,
Joern.
p.s.: As always: Thank you very much for protobuf!
--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.