How do I Share Enum values between my Java code and .proto file

后端 未结 1 1826
醉话见心
醉话见心 2021-01-26 04:12

I have a class that I wish to protobuf. in that class one of the fields is an enum (in a class of it\'s own). Can I avoid defining an identical enum value in my .proto file ? Or

相关标签:
1条回答
  • 2021-01-26 04:33

    The best solution for keeping things like this in sync is often code generation; determine which of your definitions is the Single Point of Truth, and create the others from it. Protocol Buffers has built-in support for Java code generation with nifty features like automatically handling duplicate enum values.

    0 讨论(0)
提交回复
热议问题