jhunters / jprotobuf

A useful utility library for java programmer using google protobuf
Apache License 2.0
879 stars 281 forks source link

pb3转换添加字段默认值? #131

Closed FancyJan closed 4 years ago

FancyJan commented 4 years ago

jprotobuf 2.x 能不能支持生成的java文件的字段按照类型带默认值

FancyJan commented 4 years ago

jprotobuf 2.x 能不能支持生成的java文件的字段按照类型带默认值

比如 proto里面 int a = 1;string b = 2; 在 生成的java文件里面 @Protobuf(fieldType=FieldType.INT32, order=1, required=false) public String a = 0; @Protobuf(fieldType=FieldType.STRING, order=2, required=false) public String b = "";

jhunters commented 4 years ago

指 从proto文件,生成jprotobuf java 代码,带上默认值 ,是这个意思吗?

FancyJan commented 4 years ago

指 从proto文件,生成jprotobuf java 代码,带上默认值 ,是这个意思吗?

是的

jhunters commented 4 years ago

现在好像已经支持 ,使用方式如 string message = 1 [default = \"hello\"];