Netty学习——protoc的新手使用流程
关于学习的内容笔记,记下来的东西等于又过了一次脑子,记录的更深刻一些。
1. 使用IDEA创建.proto文件,软件会提示你安装相应的语法插件
安装成功之后,proto文件的显示图标是这个样子的
2. 编写Proto文件
syntax ="proto2"; package com.dawa.protobuf; option optimize_for = SPEED; option java_package ="com.dawa.protobuf"; option java_outer_classname = "DataInfo"; message Student{ required string name = 1; optional int32 age = 2; optional string address = 3; }
提示:关于Gradle的使用,Gradle文件在引用Jar包的时候,需要格外注意语法的正确与否。
(我刚生成的文件,里面大量的报错,经过检查,是因为Gradle里面的语法没有写正确,导致包没有正常的导入)下面是正确的Gradle语句
dependencies { compile( "io.netty:netty-all:4.1.43.Final", "com.google.protobuf:protobuf-java-util:3.11.0", "com.google.protobuf:protobuf-java:3.11.0" ) }
注释: optimize_for 属性 : 加快解析速度 (默认值为speed)
3. 然后使用命令行启动protoc来完成编译工作
如果执行完之后,没有任何提示,代表执行完成,在自己指定的目录里即可看到生成的java文件
提示:绝对不要修改使用Protobuf自动生成的Java文件
关于protoc的语法,可以输入指令 protoc -h 自行查阅
我这里使用的是指定生成java位置的这条语法
4. 测试调用生成的文件,是否可以正常使用。
这个案例,看着简单,其实非常具备代表性,
首先里面先转换成字节数组(这意味能够使用字节数组在网络上进行传输)
然后再将字节数组转换成对象(这意味着能够前端后端不是同种语言,通过字节来进行信息传递)
public class ProtobufTest { public static void main(String[] args) throws InvalidProtocolBufferException { DataInfo.Student student = DataInfo.Student.newBuilder() .setName("大娃").setAge(22).setAddress("北京").build(); //转换成字节数组 byte[] student2ByteArray = student.toByteArray(); //字节就可以在网络上进行传输了。 //字节可以是java语言,也可以是其他语言,如Python //再将字节数组,解析成对象 DataInfo.Student student1 = DataInfo.Student.parseFrom(student2ByteArray); System.out.println(student1.getName()); System.out.println(student1.getAge()); System.out.println(student1.getAddress()); } }
以上,这个Protobuf的工具使用和验证就结束了。接下来需要借助Netty来实现网络的通讯,Netty很好的继承的Protobuf,只需要设定自定义的Handler可以方面使用。
自动生成的文件,也提供一下。
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: src/protobuf/Student.proto package com.dawa.protobuf; public final class DataInfo { private DataInfo() {} 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 StudentOrBuilder extends // @@protoc_insertion_point(interface_extends:com.dawa.protobuf.Student) com.google.protobuf.MessageOrBuilder { /** *required string name = 1;
* @return Whether the name field is set. */ boolean hasName(); /** *required string name = 1;
* @return The name. */ java.lang.String getName(); /** *required string name = 1;
* @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); /** *optional int32 age = 2;
* @return Whether the age field is set. */ boolean hasAge(); /** *optional int32 age = 2;
* @return The age. */ int getAge(); /** *optional string address = 3;
* @return Whether the address field is set. */ boolean hasAddress(); /** *optional string address = 3;
* @return The address. */ java.lang.String getAddress(); /** *optional string address = 3;
* @return The bytes for address. */ com.google.protobuf.ByteString getAddressBytes(); } /** * Protobuf type {@code com.dawa.protobuf.Student} */ public static final class Student extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:com.dawa.protobuf.Student) StudentOrBuilder { private static final long serialVersionUID = 0L; // Use Student.newBuilder() to construct. private Student(com.google.protobuf.GeneratedMessageV3.Builder> builder) { super(builder); } private Student() { name_ = ""; address_ = ""; } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance( UnusedPrivateParameter unused) { return new Student(); } @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; } private Student( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { this(); if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } int mutable_bitField0_ = 0; 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: { com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000001; name_ = bs; break; } case 16: { bitField0_ |= 0x00000002; age_ = input.readInt32(); break; } case 26: { com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000004; address_ = bs; 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 com.dawa.protobuf.DataInfo.internal_static_com_dawa_protobuf_Student_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.dawa.protobuf.DataInfo.internal_static_com_dawa_protobuf_Student_fieldAccessorTable .ensureFieldAccessorsInitialized( com.dawa.protobuf.DataInfo.Student.class, com.dawa.protobuf.DataInfo.Student.Builder.class); } private int bitField0_; public static final int NAME_FIELD_NUMBER = 1; private volatile java.lang.Object name_; /** *required string name = 1;
* @return Whether the name field is set. */ public boolean hasName() { return ((bitField0_ & 0x00000001) != 0); } /** *required string name = 1;
* @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; 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(); if (bs.isValidUtf8()) { name_ = s; } return s; } } /** *required string name = 1;
* @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); name_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } public static final int AGE_FIELD_NUMBER = 2; private int age_; /** *optional int32 age = 2;
* @return Whether the age field is set. */ public boolean hasAge() { return ((bitField0_ & 0x00000002) != 0); } /** *optional int32 age = 2;
* @return The age. */ public int getAge() { return age_; } public static final int ADDRESS_FIELD_NUMBER = 3; private volatile java.lang.Object address_; /** *optional string address = 3;
* @return Whether the address field is set. */ public boolean hasAddress() { return ((bitField0_ & 0x00000004) != 0); } /** *optional string address = 3;
* @return The address. */ public java.lang.String getAddress() { java.lang.Object ref = address_; 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(); if (bs.isValidUtf8()) { address_ = s; } return s; } } /** *optional string address = 3;
* @return The bytes for address. */ public com.google.protobuf.ByteString getAddressBytes() { java.lang.Object ref = address_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); address_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; if (!hasName()) { memoizedIsInitialized = 0; return false; } memoizedIsInitialized = 1; return true; } @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) != 0)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); } if (((bitField0_ & 0x00000002) != 0)) { output.writeInt32(2, age_); } if (((bitField0_ & 0x00000004) != 0)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 3, address_); } unknownFields.writeTo(output); } @java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) != 0)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); } if (((bitField0_ & 0x00000002) != 0)) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(2, age_); } if (((bitField0_ & 0x00000004) != 0)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, address_); } 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 com.dawa.protobuf.DataInfo.Student)) { return super.equals(obj); } com.dawa.protobuf.DataInfo.Student other = (com.dawa.protobuf.DataInfo.Student) obj; if (hasName() != other.hasName()) return false; if (hasName()) { if (!getName() .equals(other.getName())) return false; } if (hasAge() != other.hasAge()) return false; if (hasAge()) { if (getAge() != other.getAge()) return false; } if (hasAddress() != other.hasAddress()) return false; if (hasAddress()) { if (!getAddress() .equals(other.getAddress())) 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(); if (hasName()) { hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); } if (hasAge()) { hash = (37 * hash) + AGE_FIELD_NUMBER; hash = (53 * hash) + getAge(); } if (hasAddress()) { hash = (37 * hash) + ADDRESS_FIELD_NUMBER; hash = (53 * hash) + getAddress().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } public static com.dawa.protobuf.DataInfo.Student parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static com.dawa.protobuf.DataInfo.Student parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static com.dawa.protobuf.DataInfo.Student parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static com.dawa.protobuf.DataInfo.Student parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static com.dawa.protobuf.DataInfo.Student parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static com.dawa.protobuf.DataInfo.Student parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static com.dawa.protobuf.DataInfo.Student parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static com.dawa.protobuf.DataInfo.Student 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 com.dawa.protobuf.DataInfo.Student parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } public static com.dawa.protobuf.DataInfo.Student 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 com.dawa.protobuf.DataInfo.Student parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static com.dawa.protobuf.DataInfo.Student 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(com.dawa.protobuf.DataInfo.Student 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 com.dawa.protobuf.Student} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builderimplements // @@protoc_insertion_point(builder_implements:com.dawa.protobuf.Student) com.dawa.protobuf.DataInfo.StudentOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return com.dawa.protobuf.DataInfo.internal_static_com_dawa_protobuf_Student_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.dawa.protobuf.DataInfo.internal_static_com_dawa_protobuf_Student_fieldAccessorTable .ensureFieldAccessorsInitialized( com.dawa.protobuf.DataInfo.Student.class, com.dawa.protobuf.DataInfo.Student.Builder.class); } // Construct using com.dawa.protobuf.DataInfo.Student.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(); name_ = ""; bitField0_ = (bitField0_ & ~0x00000001); age_ = 0; bitField0_ = (bitField0_ & ~0x00000002); address_ = ""; bitField0_ = (bitField0_ & ~0x00000004); return this; } @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return com.dawa.protobuf.DataInfo.internal_static_com_dawa_protobuf_Student_descriptor; } @java.lang.Override public com.dawa.protobuf.DataInfo.Student getDefaultInstanceForType() { return com.dawa.protobuf.DataInfo.Student.getDefaultInstance(); } @java.lang.Override public com.dawa.protobuf.DataInfo.Student build() { com.dawa.protobuf.DataInfo.Student result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } @java.lang.Override public com.dawa.protobuf.DataInfo.Student buildPartial() { com.dawa.protobuf.DataInfo.Student result = new com.dawa.protobuf.DataInfo.Student(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) != 0)) { to_bitField0_ |= 0x00000001; } result.name_ = name_; if (((from_bitField0_ & 0x00000002) != 0)) { result.age_ = age_; to_bitField0_ |= 0x00000002; } if (((from_bitField0_ & 0x00000004) != 0)) { to_bitField0_ |= 0x00000004; } result.address_ = address_; result.bitField0_ = to_bitField0_; 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 com.dawa.protobuf.DataInfo.Student) { return mergeFrom((com.dawa.protobuf.DataInfo.Student)other); } else { super.mergeFrom(other); return this; } } public Builder mergeFrom(com.dawa.protobuf.DataInfo.Student other) { if (other == com.dawa.protobuf.DataInfo.Student.getDefaultInstance()) return this; if (other.hasName()) { bitField0_ |= 0x00000001; name_ = other.name_; onChanged(); } if (other.hasAge()) { setAge(other.getAge()); } if (other.hasAddress()) { bitField0_ |= 0x00000004; address_ = other.address_; onChanged(); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; } @java.lang.Override public final boolean isInitialized() { if (!hasName()) { return false; } return true; } @java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.dawa.protobuf.DataInfo.Student parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (com.dawa.protobuf.DataInfo.Student) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; } private int bitField0_; private java.lang.Object name_ = ""; /** * required string name = 1;
* @return Whether the name field is set. */ public boolean hasName() { return ((bitField0_ & 0x00000001) != 0); } /** *required string name = 1;
* @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { name_ = s; } return s; } else { return (java.lang.String) ref; } } /** *required string name = 1;
* @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); name_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** *required string name = 1;
* @param value The name to set. * @return This builder for chaining. */ public Builder setName( java.lang.String value) { if (value == null) { throw new NullPointerException(); } bitField0_ |= 0x00000001; name_ = value; onChanged(); return this; } /** *required string name = 1;
* @return This builder for chaining. */ public Builder clearName() { bitField0_ = (bitField0_ & ~0x00000001); name_ = getDefaultInstance().getName(); onChanged(); return this; } /** *required string name = 1;
* @param value The bytes for name to set. * @return This builder for chaining. */ public Builder setNameBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } bitField0_ |= 0x00000001; name_ = value; onChanged(); return this; } private int age_ ; /** *optional int32 age = 2;
* @return Whether the age field is set. */ public boolean hasAge() { return ((bitField0_ & 0x00000002) != 0); } /** *optional int32 age = 2;
* @return The age. */ public int getAge() { return age_; } /** *optional int32 age = 2;
* @param value The age to set. * @return This builder for chaining. */ public Builder setAge(int value) { bitField0_ |= 0x00000002; age_ = value; onChanged(); return this; } /** *optional int32 age = 2;
* @return This builder for chaining. */ public Builder clearAge() { bitField0_ = (bitField0_ & ~0x00000002); age_ = 0; onChanged(); return this; } private java.lang.Object address_ = ""; /** *optional string address = 3;
* @return Whether the address field is set. */ public boolean hasAddress() { return ((bitField0_ & 0x00000004) != 0); } /** *optional string address = 3;
* @return The address. */ public java.lang.String getAddress() { java.lang.Object ref = address_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); if (bs.isValidUtf8()) { address_ = s; } return s; } else { return (java.lang.String) ref; } } /** *optional string address = 3;
* @return The bytes for address. */ public com.google.protobuf.ByteString getAddressBytes() { java.lang.Object ref = address_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); address_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** *optional string address = 3;
* @param value The address to set. * @return This builder for chaining. */ public Builder setAddress( java.lang.String value) { if (value == null) { throw new NullPointerException(); } bitField0_ |= 0x00000004; address_ = value; onChanged(); return this; } /** *optional string address = 3;
* @return This builder for chaining. */ public Builder clearAddress() { bitField0_ = (bitField0_ & ~0x00000004); address_ = getDefaultInstance().getAddress(); onChanged(); return this; } /** *optional string address = 3;
* @param value The bytes for address to set. * @return This builder for chaining. */ public Builder setAddressBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } bitField0_ |= 0x00000004; address_ = value; 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:com.dawa.protobuf.Student) } // @@protoc_insertion_point(class_scope:com.dawa.protobuf.Student) private static final com.dawa.protobuf.DataInfo.Student DEFAULT_INSTANCE; static { DEFAULT_INSTANCE = new com.dawa.protobuf.DataInfo.Student(); } public static com.dawa.protobuf.DataInfo.Student getDefaultInstance() { return DEFAULT_INSTANCE; } @java.lang.Deprecated public static final com.google.protobuf.ParserPARSER = new com.google.protobuf.AbstractParser () { @java.lang.Override public Student parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return new Student(input, extensionRegistry); } }; public static com.google.protobuf.Parser parser() { return PARSER; } @java.lang.Override public com.google.protobuf.Parser getParserForType() { return PARSER; } @java.lang.Override public com.dawa.protobuf.DataInfo.Student getDefaultInstanceForType() { return DEFAULT_INSTANCE; } } private static final com.google.protobuf.Descriptors.Descriptor internal_static_com_dawa_protobuf_Student_descriptor; private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_com_dawa_protobuf_Student_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\032src/protobuf/Student.proto\022\021com.dawa.p" + "rotobuf\"5\n\007Student\022\014\n\004name\030\001 \002(\t\022\013\n\003age\030" + "\002 \001(\005\022\017\n\007address\030\003 \001(\tB\037\n\021com.dawa.proto" + "bufB\010DataInfoH\001" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { }); internal_static_com_dawa_protobuf_Student_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_com_dawa_protobuf_Student_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_com_dawa_protobuf_Student_descriptor, new java.lang.String[] { "Name", "Age", "Address", }); } // @@protoc_insertion_point(outer_class_scope) }