Currently in Java, one must compare the value of the oneof enum to know which field is contain in a oneof.
This is not very friendly to the end-user especially when you want to use oneof to provide nullability of the field. A generated hasXXX() method would be much more handy.
Also, I use mapstruct to map the generated protobuf classes to internal POJOs and it is capable of detecting if there is a hasFoo()
method for a given foo
field and using it in the mapping code it generates (see http://mapstruct.org/documentation/stable/reference/html/#source-presence-check). So such an enhancement would allow me to remove a lot of boilerplate code.
Read full article from [Java] Generate hasXXX() methods for fields inside a oneof · Issue #2984 · protocolbuffers/protobuf · GitHub
No comments:
Post a Comment