我想将原始反序列化的Builder转换为java Constructor,它需要处理wrapper类。如果没有分配,它将变为NULL。
1。使用反射(问题:反射性能差)https://github.com/singgel/protobuf-converter 2.一对一地使用构造函数(问题:重复编码过多)
例如:原始
syntax = "proto3";
import "google/protobuf/wrappers.proto";
option java_outer_classname = "PeopleProto";
message People {
int32 personId = 1;
string personName = 2;
google.protobuf.StringValue sex = 3;
repeated string address = 4;
}
java
public class People {
private int personId;
private String personName;
private String sex;
List<String> address;
...
}
byte[] bb = ...;
People people = InterClassName.parseFrom(bb);