jprotobuf icon indicating copy to clipboard operation
jprotobuf copied to clipboard

DEFAULT_SUFFIX_CLASSNAME 可以自定义吗?

Open id55503 opened this issue 6 years ago • 7 comments

用proto文件生成java class名字最后不想带JProtoBufProtoClass,或者能否自定义

id55503 avatar Nov 07 '18 07:11 id55503

可以,需要复写 ICodeGenerator 接口的getClassName方法 ProtobufProxy public static <T> Codec<T> create(Class<T> cls, Compiler compiler, ICodeGenerator codeGenerator)

xiemalin avatar Nov 22 '18 10:11 xiemalin

同问: 我继承了TemplateCodeGenerator重写了 getClassName方法,调用create失败了

xjsunup avatar Mar 25 '19 06:03 xjsunup

getClassName实现的代码以及错误内容贴一下出来

jhunters avatar Mar 25 '19 06:03 jhunters

getClassName实现的代码以及错误内容贴一下出来

image image

xjsunup avatar Mar 25 '19 06:03 xjsunup

这个getName实现有问题,不能生成的类名与原类名相同的

jhunters avatar Mar 25 '19 07:03 jhunters

这个getName实现有问题,不能生成的类名与原类名相同的 message 名不能与生成出来的pojo名一致对吗。

xjsunup avatar Mar 25 '19 07:03 xjsunup

因为是动态生成一个新的类,这个新的类名不能与POJO类名一样,否则jdk加载出错。 你加一个后缀与前缀区分一下就行

jhunters avatar Mar 25 '19 07:03 jhunters