发布于2021-05-29 19:32 阅读(746) 评论(0) 点赞(18) 收藏(3)
不同版本生成的类文件不同。
//TODO
不同版本生成的类不同,因此生成类的版本与依赖版本要一致。
版本:3.16.0
下载地址:https://github.com/protocolbuffers/protobuf/releases
syntax = "proto3";
package common.entity;
message User {
string username = 1;
string sex = 2;
int32 age = 3;
}
通过终端进入解压后的protobuf的bin目录
protoc --proto_path=D:\JProject\jiguang_test --java_out=D:\JProject\jiguang_test\test D:\JProject\jiguang_test\user-from-proto.proto
序号 | 参数 | 描述 |
---|---|---|
1 | proto_path | *.proto文件所在的路径,用于扫描 *.proto文件 |
2 | java_out | 生成java文件的路径 |
3 | D:\JProject\jiguang_test\user-from-proto.proto | 指定proto文件所在的路径 |
<properties>
<commons-lang3.version>3.11</commons-lang3.version>
<bean-utils.version>1.9.4</bean-utils.version>
<druid.version>1.1.10</druid.version>
<protobuf.java.version>3.16.0-rc-2</protobuf.java.version>
<protobuf.java.util.version>3.16.0-rc-2</protobuf.java.util.version>
<protobuf.java.format.version>1.4</protobuf.java.format.version>
</properties>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf.java.version}</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>${protobuf.java.util.version}</version>
</dependency>
<dependency>
<groupId>com.googlecode.protobuf-java-format</groupId>
<artifactId>protobuf-java-format</artifactId>
<version>${protobuf.java.format.version}</version>
</dependency>
package datastructure;
import com.google.protobuf.InvalidProtocolBufferException;
import common.entity.UserFromProto;
import java.util.logging.Logger;
import static common.constant.DigitalConstant.SIX;
/**
* Google proto数据序列化测试.
*
* @author xindaqi
* @date 2021-05-08 9:59
*/
public class GoogleProtoTest {
private static final Logger logger = Logger.getLogger("GoogleProtoTest");
/**
* 通过Google protobuf创建类
*
* @return 对象字节数组
* @throws InvalidProtocolBufferException
*/
public static byte[] createObjectFromProto() throws InvalidProtocolBufferException {
UserFromProto.User.Builder userBuilder = UserFromProto.User.newBuilder();
userBuilder.setAge(SIX)
.setUsername("xiaoxiao")
.setSex("male");
logger.info("Proto创建的类:" + userBuilder);
return userBuilder.build().toByteArray();
}
public static void main(String[] args) {
try {
byte[] params = createObjectFromProto();
} catch(InvalidProtocolBufferException ipe) {
throw new RuntimeException(ipe);
} catch(Exception e) {
throw new RuntimeException(e);
}
}
}
package datastructure;
import com.google.protobuf.InvalidProtocolBufferException;
import common.entity.UserFromProto;
import java.util.logging.Logger;
import static common.constant.DigitalConstant.SIX;
/**
* Google proto数据序列化测试.
*
* @author xindaqi
* @date 2021-05-08 9:59
*/
public class GoogleProtoTest {
private static final Logger logger = Logger.getLogger("GoogleProtoTest");
/**
* 通过Google protobuf创建类
*
* @return 对象字节数组
* @throws InvalidProtocolBufferException
*/
public static byte[] createObjectFromProto() throws InvalidProtocolBufferException {
UserFromProto.User.Builder userBuilder = UserFromProto.User.newBuilder();
userBuilder.setAge(SIX)
.setUsername("xiaoxiao")
.setSex("male");
logger.info("Proto创建的类:" + userBuilder);
return userBuilder.build().toByteArray();
}
/**
* 解析字节数组,转换为对象
*
* @param params 字节数组
* @throws InvalidProtocolBufferException
*/
public static void parseObjectFromProto(byte[] params) throws InvalidProtocolBufferException {
logger.info("入参:" + params);
UserFromProto.User user = UserFromProto.User.parseFrom(params);
logger.info("Proto解析字节结果:" + user);
logger.info("username: " + user.getUsername());
}
public static void main(String[] args) {
try {
byte[] params = createObjectFromProto();
parseObjectFromProto(params);
} catch(InvalidProtocolBufferException ipe) {
throw new RuntimeException(ipe);
} catch(Exception e) {
throw new RuntimeException(e);
}
}
}
五月 08, 2021 10:54:57 上午 datastructure.GoogleProtoTest parseObjectFromProto
信息: username: xiaoxiao
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: user-from-proto.proto
package common.entity;
public final class UserFromProto {
private UserFromProto() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
public interface UserOrBuilder extends
// @@protoc_insertion_point(interface_extends:common.entity.User)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string username = 1;</code>
* @return The username.
*/
java.lang.String getUsername();
/**
* <code>string username = 1;</code>
* @return The bytes for username.
*/
com.google.protobuf.ByteString
getUsernameBytes();
/**
* <code>string sex = 2;</code>
* @return The sex.
*/
java.lang.String getSex();
/**
* <code>string sex = 2;</code>
* @return The bytes for sex.
*/
com.google.protobuf.ByteString
getSexBytes();
/**
* <code>int32 age = 3;</code>
* @return The age.
*/
int getAge();
}
/**
* Protobuf type {@code common.entity.User}
*/
public static final class User extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:common.entity.User)
UserOrBuilder {
private static final long serialVersionUID = 0L;
// Use User.newBuilder() to construct.
private User(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private User() {
username_ = "";
sex_ = "";
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new User();
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private User(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new java.lang.NullPointerException();
}
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 10: {
java.lang.String s = input.readStringRequireUtf8();
username_ = s;
break;
}
case 18: {
java.lang.String s = input.readStringRequireUtf8();
sex_ = s;
break;
}
case 24: {
age_ = input.readInt32();
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return common.entity.UserFromProto.internal_static_common_entity_User_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return common.entity.UserFromProto.internal_static_common_entity_User_fieldAccessorTable
.ensureFieldAccessorsInitialized(
common.entity.UserFromProto.User.class, common.entity.UserFromProto.User.Builder.class);
}
public static final int USERNAME_FIELD_NUMBER = 1;
private volatile java.lang.Object username_;
/**
* <code>string username = 1;</code>
* @return The username.
*/
@java.lang.Override
public java.lang.String getUsername() {
java.lang.Object ref = username_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
username_ = s;
return s;
}
}
/**
* <code>string username = 1;</code>
* @return The bytes for username.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getUsernameBytes() {
java.lang.Object ref = username_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
username_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int SEX_FIELD_NUMBER = 2;
private volatile java.lang.Object sex_;
/**
* <code>string sex = 2;</code>
* @return The sex.
*/
@java.lang.Override
public java.lang.String getSex() {
java.lang.Object ref = sex_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
sex_ = s;
return s;
}
}
/**
* <code>string sex = 2;</code>
* @return The bytes for sex.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getSexBytes() {
java.lang.Object ref = sex_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
sex_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int AGE_FIELD_NUMBER = 3;
private int age_;
/**
* <code>int32 age = 3;</code>
* @return The age.
*/
@java.lang.Override
public int getAge() {
return age_;
}
private byte memoizedIsInitialized = -1;
@java.lang.Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@java.lang.Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!getUsernameBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, username_);
}
if (!getSexBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, sex_);
}
if (age_ != 0) {
output.writeInt32(3, age_);
}
unknownFields.writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!getUsernameBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, username_);
}
if (!getSexBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, sex_);
}
if (age_ != 0) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(3, age_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof common.entity.UserFromProto.User)) {
return super.equals(obj);
}
common.entity.UserFromProto.User other = (common.entity.UserFromProto.User) obj;
if (!getUsername()
.equals(other.getUsername())) return false;
if (!getSex()
.equals(other.getSex())) return false;
if (getAge()
!= other.getAge()) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@java.lang.Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + USERNAME_FIELD_NUMBER;
hash = (53 * hash) + getUsername().hashCode();
hash = (37 * hash) + SEX_FIELD_NUMBER;
hash = (53 * hash) + getSex().hashCode();
hash = (37 * hash) + AGE_FIELD_NUMBER;
hash = (53 * hash) + getAge();
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static common.entity.UserFromProto.User parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static common.entity.UserFromProto.User parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static common.entity.UserFromProto.User parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static common.entity.UserFromProto.User parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static common.entity.UserFromProto.User parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static common.entity.UserFromProto.User parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static common.entity.UserFromProto.User parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static common.entity.UserFromProto.User parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static common.entity.UserFromProto.User parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static common.entity.UserFromProto.User parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static common.entity.UserFromProto.User parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static common.entity.UserFromProto.User parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@java.lang.Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(common.entity.UserFromProto.User prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@java.lang.Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code common.entity.User}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:common.entity.User)
common.entity.UserFromProto.UserOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return common.entity.UserFromProto.internal_static_common_entity_User_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return common.entity.UserFromProto.internal_static_common_entity_User_fieldAccessorTable
.ensureFieldAccessorsInitialized(
common.entity.UserFromProto.User.class, common.entity.UserFromProto.User.Builder.class);
}
// Construct using common.entity.UserFromProto.User.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
@java.lang.Override
public Builder clear() {
super.clear();
username_ = "";
sex_ = "";
age_ = 0;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return common.entity.UserFromProto.internal_static_common_entity_User_descriptor;
}
@java.lang.Override
public common.entity.UserFromProto.User getDefaultInstanceForType() {
return common.entity.UserFromProto.User.getDefaultInstance();
}
@java.lang.Override
public common.entity.UserFromProto.User build() {
common.entity.UserFromProto.User result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public common.entity.UserFromProto.User buildPartial() {
common.entity.UserFromProto.User result = new common.entity.UserFromProto.User(this);
result.username_ = username_;
result.sex_ = sex_;
result.age_ = age_;
onBuilt();
return result;
}
@java.lang.Override
public Builder clone() {
return super.clone();
}
@java.lang.Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.setField(field, value);
}
@java.lang.Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@java.lang.Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@java.lang.Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, java.lang.Object value) {
return super.setRepeatedField(field, index, value);
}
@java.lang.Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.addRepeatedField(field, value);
}
@java.lang.Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof common.entity.UserFromProto.User) {
return mergeFrom((common.entity.UserFromProto.User)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(common.entity.UserFromProto.User other) {
if (other == common.entity.UserFromProto.User.getDefaultInstance()) return this;
if (!other.getUsername().isEmpty()) {
username_ = other.username_;
onChanged();
}
if (!other.getSex().isEmpty()) {
sex_ = other.sex_;
onChanged();
}
if (other.getAge() != 0) {
setAge(other.getAge());
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@java.lang.Override
public final boolean isInitialized() {
return true;
}
@java.lang.Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
common.entity.UserFromProto.User parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (common.entity.UserFromProto.User) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private java.lang.Object username_ = "";
/**
* <code>string username = 1;</code>
* @return The username.
*/
public java.lang.String getUsername() {
java.lang.Object ref = username_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
username_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <code>string username = 1;</code>
* @return The bytes for username.
*/
public com.google.protobuf.ByteString
getUsernameBytes() {
java.lang.Object ref = username_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
username_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string username = 1;</code>
* @param value The username to set.
* @return This builder for chaining.
*/
public Builder setUsername(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
username_ = value;
onChanged();
return this;
}
/**
* <code>string username = 1;</code>
* @return This builder for chaining.
*/
public Builder clearUsername() {
username_ = getDefaultInstance().getUsername();
onChanged();
return this;
}
/**
* <code>string username = 1;</code>
* @param value The bytes for username to set.
* @return This builder for chaining.
*/
public Builder setUsernameBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
username_ = value;
onChanged();
return this;
}
private java.lang.Object sex_ = "";
/**
* <code>string sex = 2;</code>
* @return The sex.
*/
public java.lang.String getSex() {
java.lang.Object ref = sex_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
sex_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <code>string sex = 2;</code>
* @return The bytes for sex.
*/
public com.google.protobuf.ByteString
getSexBytes() {
java.lang.Object ref = sex_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
sex_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string sex = 2;</code>
* @param value The sex to set.
* @return This builder for chaining.
*/
public Builder setSex(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
sex_ = value;
onChanged();
return this;
}
/**
* <code>string sex = 2;</code>
* @return This builder for chaining.
*/
public Builder clearSex() {
sex_ = getDefaultInstance().getSex();
onChanged();
return this;
}
/**
* <code>string sex = 2;</code>
* @param value The bytes for sex to set.
* @return This builder for chaining.
*/
public Builder setSexBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
sex_ = value;
onChanged();
return this;
}
private int age_ ;
/**
* <code>int32 age = 3;</code>
* @return The age.
*/
@java.lang.Override
public int getAge() {
return age_;
}
/**
* <code>int32 age = 3;</code>
* @param value The age to set.
* @return This builder for chaining.
*/
public Builder setAge(int value) {
age_ = value;
onChanged();
return this;
}
/**
* <code>int32 age = 3;</code>
* @return This builder for chaining.
*/
public Builder clearAge() {
age_ = 0;
onChanged();
return this;
}
@java.lang.Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@java.lang.Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:common.entity.User)
}
// @@protoc_insertion_point(class_scope:common.entity.User)
private static final common.entity.UserFromProto.User DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new common.entity.UserFromProto.User();
}
public static common.entity.UserFromProto.User getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<User>
PARSER = new com.google.protobuf.AbstractParser<User>() {
@java.lang.Override
public User parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new User(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<User> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<User> getParserForType() {
return PARSER;
}
@java.lang.Override
public common.entity.UserFromProto.User getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
private static final com.google.protobuf.Descriptors.Descriptor
internal_static_common_entity_User_descriptor;
private static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_common_entity_User_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\025user-from-proto.proto\022\rcommon.entity\"2" +
"\n\004User\022\020\n\010username\030\001 \001(\t\022\013\n\003sex\030\002 \001(\t\022\013\n" +
"\003age\030\003 \001(\005b\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
});
internal_static_common_entity_User_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_common_entity_User_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_common_entity_User_descriptor,
new java.lang.String[] { "Username", "Sex", "Age", });
}
// @@protoc_insertion_point(outer_class_scope)
}
作者:helloworld
链接:http://www.javaheidong.com/blog/article/207209/75387270690ac666867d/
来源:java黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 java黑洞网 All Rights Reserved 版权所有,并保留所有权利。京ICP备18063182号-2
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!