How do I make Java protocol buffer types mutable?
Protoc.exe doesn't generate setters?
Basically I need to create an object then change a field value.
Thanks
For a oneof field, the protobuf compiler generates a single field with an interface type isMessageName_MyField . It also generates a struct for each of the singular fields within the oneof. These all implement this isMessageName_MyField interface.
Protocol buffers are a combination of the definition language (created in . proto files), the code that the proto compiler generates to interface with data, language-specific runtime libraries, and the serialization format for data that is written to a file (or sent across a network connection).
Yes, you can absolutely combine Protobuf and REST.
That isn't the intended usages of the library; you would set the values at the builder stage, then create the immutable DTO from the builder. If you want different values: change the value in the builder and regenerate the DTO.
Alternatively, note that there are multiple libraries providing support for the protobuf wire specification. IIRC "protostuff" works with mutable POJO objects.
You can simply use builders everywhere where you still want objects to be mutable. They have both getters and setters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With