protoc编译proto文件之Java源码结构分析二(person.proto)

一、person.proto

option java_package = "com.test.protocol";
option java_outer_classname = "PersonProto";

import "addr.proto";

message Person {
    optional string name = 1;
    optional string idNum = 2;
    optional Address address = 3; //引用addr.proto的Address
}

二、PersonProto.java结构分析

代码结构分析过程和博文protoc编译proto文件之Java源码结构分析一(addr.proto)相同。

这里需要注意的是原型文件person.proto中引用了addr.proto,在message Person中有一field为optional Address address = 3,所以在类Person.Builder中该field的setter方法为setAddress(Builder)。该方法具体如何使用,可参考博文protoc编译proto文件之Java源码结构分析三(示例Demo)

三、PersonProto.java完整代码

// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: person.proto

package com.test.protocol;

public final class PersonProto {
  private PersonProto() {}
  public static void registerAllExtensions(
      com.google.protobuf.ExtensionRegistry registry) {
  }
  public interface PersonOrBuilder
      extends com.google.protobuf.MessageOrBuilder {

    // optional string name = 1;
    /**
     * <code>optional string name = 1;</code>
     */
    boolean hasName();
    /**
     * <code>optional string name = 1;</code>
     */
    java.lang.String getName();
    /**
     * <code>optional string name = 1;</code>
     */
    com.google.protobuf.ByteString
        getNameBytes();

    // optional string idNum = 2;
    /**
     * <code>optional string idNum = 2;</code>
     */
    boolean hasIdNum();
    /**
     * <code>optional string idNum = 2;</code>
     */
    java.lang.String getIdNum();
    /**
     * <code>optional string idNum = 2;</code>
     */
    com.google.protobuf.ByteString
        getIdNumBytes();

    // optional .Address address = 3;
    /**
     * <code>optional .Address address = 3;</code>
     */
    boolean hasAddress();
    /**
     * <code>optional .Address address = 3;</code>
     */
    com.test.protocol.AddressProto.Address getAddress();
    /**
     * <code>optional .Address address = 3;</code>
     */
    com.test.protocol.AddressProto.AddressOrBuilder getAddressOrBuilder();
  }
  /**
   * Protobuf type {@code Person}
   */
  public static final class Person extends
      com.google.protobuf.GeneratedMessage
      implements PersonOrBuilder {
    // Use Person.newBuilder() to construct.
    private Person(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
      super(builder);
      this.unknownFields = builder.getUnknownFields();
    }
    private Person(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }

    private static final Person defaultInstance;
    public static Person getDefaultInstance() {
      return defaultInstance;
    }

    public Person getDefaultInstanceForType() {
      return defaultInstance;
    }

    private final com.google.protobuf.UnknownFieldSet unknownFields;
    @java.lang.Override
    public final com.google.protobuf.UnknownFieldSet
        getUnknownFields() {
      return this.unknownFields;
    }
    private Person(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      initFields();
      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;
            default: {
              if (!parseUnknownField(input, unknownFields,
                                     extensionRegistry, tag)) {
                done = true;
              }
              break;
            }
            case 10: {
              bitField0_ |= 0x00000001;
              name_ = input.readBytes();
              break;
            }
            case 18: {
              bitField0_ |= 0x00000002;
              idNum_ = input.readBytes();
              break;
            }
            case 26: {
              com.test.protocol.AddressProto.Address.Builder subBuilder = null;
              if (((bitField0_ & 0x00000004) == 0x00000004)) {
                subBuilder = address_.toBuilder();
              }
              address_ = input.readMessage(com.test.protocol.AddressProto.Address.PARSER, extensionRegistry);
              if (subBuilder != null) {
                subBuilder.mergeFrom(address_);
                address_ = subBuilder.buildPartial();
              }
              bitField0_ |= 0x00000004;
              break;
            }
          }
        }
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.setUnfinishedMessage(this);
      } catch (java.io.IOException e) {
        throw new com.google.protobuf.InvalidProtocolBufferException(
            e.getMessage()).setUnfinishedMessage(this);
      } finally {
        this.unknownFields = unknownFields.build();
        makeExtensionsImmutable();
      }
    }
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return com.test.protocol.PersonProto.internal_static_Person_descriptor;
    }

    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.test.protocol.PersonProto.internal_static_Person_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.test.protocol.PersonProto.Person.class, com.test.protocol.PersonProto.Person.Builder.class);
    }

    public static com.google.protobuf.Parser<Person> PARSER =
        new com.google.protobuf.AbstractParser<Person>() {
      public Person parsePartialFrom(
          com.google.protobuf.CodedInputStream input,
          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
          throws com.google.protobuf.InvalidProtocolBufferException {
        return new Person(input, extensionRegistry);
      }
    };

    @java.lang.Override
    public com.google.protobuf.Parser<Person> getParserForType() {
      return PARSER;
    }

    private int bitField0_;
    // optional string name = 1;
    public static final int NAME_FIELD_NUMBER = 1;
    private java.lang.Object name_;
    /**
     * <code>optional string name = 1;</code>
     */
    public boolean hasName() {
      return ((bitField0_ & 0x00000001) == 0x00000001);
    }
    /**
     * <code>optional string name = 1;</code>
     */
    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;
      }
    }
    /**
     * <code>optional string name = 1;</code>
     */
    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;
      }
    }

    // optional string idNum = 2;
    public static final int IDNUM_FIELD_NUMBER = 2;
    private java.lang.Object idNum_;
    /**
     * <code>optional string idNum = 2;</code>
     */
    public boolean hasIdNum() {
      return ((bitField0_ & 0x00000002) == 0x00000002);
    }
    /**
     * <code>optional string idNum = 2;</code>
     */
    public java.lang.String getIdNum() {
      java.lang.Object ref = idNum_;
      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()) {
          idNum_ = s;
        }
        return s;
      }
    }
    /**
     * <code>optional string idNum = 2;</code>
     */
    public com.google.protobuf.ByteString
        getIdNumBytes() {
      java.lang.Object ref = idNum_;
      if (ref instanceof java.lang.String) {
        com.google.protobuf.ByteString b = 
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        idNum_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }

    // optional .Address address = 3;
    public static final int ADDRESS_FIELD_NUMBER = 3;
    private com.test.protocol.AddressProto.Address address_;
    /**
     * <code>optional .Address address = 3;</code>
     */
    public boolean hasAddress() {
      return ((bitField0_ & 0x00000004) == 0x00000004);
    }
    /**
     * <code>optional .Address address = 3;</code>
     */
    public com.test.protocol.AddressProto.Address getAddress() {
      return address_;
    }
    /**
     * <code>optional .Address address = 3;</code>
     */
    public com.test.protocol.AddressProto.AddressOrBuilder getAddressOrBuilder() {
      return address_;
    }

    private void initFields() {
      name_ = "";
      idNum_ = "";
      address_ = com.test.protocol.AddressProto.Address.getDefaultInstance();
    }
    private byte memoizedIsInitialized = -1;
    public final boolean isInitialized() {
      byte isInitialized = memoizedIsInitialized;
      if (isInitialized != -1) return isInitialized == 1;

      memoizedIsInitialized = 1;
      return true;
    }

    public void writeTo(com.google.protobuf.CodedOutputStream output)
                        throws java.io.IOException {
      getSerializedSize();
      if (((bitField0_ & 0x00000001) == 0x00000001)) {
        output.writeBytes(1, getNameBytes());
      }
      if (((bitField0_ & 0x00000002) == 0x00000002)) {
        output.writeBytes(2, getIdNumBytes());
      }
      if (((bitField0_ & 0x00000004) == 0x00000004)) {
        output.writeMessage(3, address_);
      }
      getUnknownFields().writeTo(output);
    }

    private int memoizedSerializedSize = -1;
    public int getSerializedSize() {
      int size = memoizedSerializedSize;
      if (size != -1) return size;

      size = 0;
      if (((bitField0_ & 0x00000001) == 0x00000001)) {
        size += com.google.protobuf.CodedOutputStream
          .computeBytesSize(1, getNameBytes());
      }
      if (((bitField0_ & 0x00000002) == 0x00000002)) {
        size += com.google.protobuf.CodedOutputStream
          .computeBytesSize(2, getIdNumBytes());
      }
      if (((bitField0_ & 0x00000004) == 0x00000004)) {
        size += com.google.protobuf.CodedOutputStream
          .computeMessageSize(3, address_);
      }
      size += getUnknownFields().getSerializedSize();
      memoizedSerializedSize = size;
      return size;
    }

    private static final long serialVersionUID = 0L;
    @java.lang.Override
    protected java.lang.Object writeReplace()
        throws java.io.ObjectStreamException {
      return super.writeReplace();
    }

    public static com.test.protocol.PersonProto.Person parseFrom(
        com.google.protobuf.ByteString data)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data);
    }
    public static com.test.protocol.PersonProto.Person parseFrom(
        com.google.protobuf.ByteString data,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data, extensionRegistry);
    }
    public static com.test.protocol.PersonProto.Person parseFrom(byte[] data)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data);
    }
    public static com.test.protocol.PersonProto.Person parseFrom(
        byte[] data,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data, extensionRegistry);
    }
    public static com.test.protocol.PersonProto.Person parseFrom(java.io.InputStream input)
        throws java.io.IOException {
      return PARSER.parseFrom(input);
    }
    public static com.test.protocol.PersonProto.Person parseFrom(
        java.io.InputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      return PARSER.parseFrom(input, extensionRegistry);
    }
    public static com.test.protocol.PersonProto.Person parseDelimitedFrom(java.io.InputStream input)
        throws java.io.IOException {
      return PARSER.parseDelimitedFrom(input);
    }
    public static com.test.protocol.PersonProto.Person parseDelimitedFrom(
        java.io.InputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      return PARSER.parseDelimitedFrom(input, extensionRegistry);
    }
    public static com.test.protocol.PersonProto.Person parseFrom(
        com.google.protobuf.CodedInputStream input)
        throws java.io.IOException {
      return PARSER.parseFrom(input);
    }
    public static com.test.protocol.PersonProto.Person parseFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      return PARSER.parseFrom(input, extensionRegistry);
    }

    public static Builder newBuilder() { return Builder.create(); }
    public Builder newBuilderForType() { return newBuilder(); }
    public static Builder newBuilder(com.test.protocol.PersonProto.Person prototype) {
      return newBuilder().mergeFrom(prototype);
    }
    public Builder toBuilder() { return newBuilder(this); }

    @java.lang.Override
    protected Builder newBuilderForType(
        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
      Builder builder = new Builder(parent);
      return builder;
    }
    /**
     * Protobuf type {@code Person}
     */
    public static final class Builder extends
        com.google.protobuf.GeneratedMessage.Builder<Builder>
       implements com.test.protocol.PersonProto.PersonOrBuilder {
      public static final com.google.protobuf.Descriptors.Descriptor
          getDescriptor() {
        return com.test.protocol.PersonProto.internal_static_Person_descriptor;
      }

      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
          internalGetFieldAccessorTable() {
        return com.test.protocol.PersonProto.internal_static_Person_fieldAccessorTable
            .ensureFieldAccessorsInitialized(
                com.test.protocol.PersonProto.Person.class, com.test.protocol.PersonProto.Person.Builder.class);
      }

      // Construct using com.test.protocol.PersonProto.Person.newBuilder()
      private Builder() {
        maybeForceBuilderInitialization();
      }

      private Builder(
          com.google.protobuf.GeneratedMessage.BuilderParent parent) {
        super(parent);
        maybeForceBuilderInitialization();
      }
      private void maybeForceBuilderInitialization() {
        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
          getAddressFieldBuilder();
        }
      }
      private static Builder create() {
        return new Builder();
      }

      public Builder clear() {
        super.clear();
        name_ = "";
        bitField0_ = (bitField0_ & ~0x00000001);
        idNum_ = "";
        bitField0_ = (bitField0_ & ~0x00000002);
        if (addressBuilder_ == null) {
          address_ = com.test.protocol.AddressProto.Address.getDefaultInstance();
        } else {
          addressBuilder_.clear();
        }
        bitField0_ = (bitField0_ & ~0x00000004);
        return this;
      }

      public Builder clone() {
        return create().mergeFrom(buildPartial());
      }

      public com.google.protobuf.Descriptors.Descriptor
          getDescriptorForType() {
        return com.test.protocol.PersonProto.internal_static_Person_descriptor;
      }

      public com.test.protocol.PersonProto.Person getDefaultInstanceForType() {
        return com.test.protocol.PersonProto.Person.getDefaultInstance();
      }

      public com.test.protocol.PersonProto.Person build() {
        com.test.protocol.PersonProto.Person result = buildPartial();
        if (!result.isInitialized()) {
          throw newUninitializedMessageException(result);
        }
        return result;
      }

      public com.test.protocol.PersonProto.Person buildPartial() {
        com.test.protocol.PersonProto.Person result = new com.test.protocol.PersonProto.Person(this);
        int from_bitField0_ = bitField0_;
        int to_bitField0_ = 0;
        if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
          to_bitField0_ |= 0x00000001;
        }
        result.name_ = name_;
        if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
          to_bitField0_ |= 0x00000002;
        }
        result.idNum_ = idNum_;
        if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
          to_bitField0_ |= 0x00000004;
        }
        if (addressBuilder_ == null) {
          result.address_ = address_;
        } else {
          result.address_ = addressBuilder_.build();
        }
        result.bitField0_ = to_bitField0_;
        onBuilt();
        return result;
      }

      public Builder mergeFrom(com.google.protobuf.Message other) {
        if (other instanceof com.test.protocol.PersonProto.Person) {
          return mergeFrom((com.test.protocol.PersonProto.Person)other);
        } else {
          super.mergeFrom(other);
          return this;
        }
      }

      public Builder mergeFrom(com.test.protocol.PersonProto.Person other) {
        if (other == com.test.protocol.PersonProto.Person.getDefaultInstance()) return this;
        if (other.hasName()) {
          bitField0_ |= 0x00000001;
          name_ = other.name_;
          onChanged();
        }
        if (other.hasIdNum()) {
          bitField0_ |= 0x00000002;
          idNum_ = other.idNum_;
          onChanged();
        }
        if (other.hasAddress()) {
          mergeAddress(other.getAddress());
        }
        this.mergeUnknownFields(other.getUnknownFields());
        return this;
      }

      public final boolean isInitialized() {
        return true;
      }

      public Builder mergeFrom(
          com.google.protobuf.CodedInputStream input,
          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
          throws java.io.IOException {
        com.test.protocol.PersonProto.Person parsedMessage = null;
        try {
          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
          parsedMessage = (com.test.protocol.PersonProto.Person) e.getUnfinishedMessage();
          throw e;
        } finally {
          if (parsedMessage != null) {
            mergeFrom(parsedMessage);
          }
        }
        return this;
      }
      private int bitField0_;

      // optional string name = 1;
      private java.lang.Object name_ = "";
      /**
       * <code>optional string name = 1;</code>
       */
      public boolean hasName() {
        return ((bitField0_ & 0x00000001) == 0x00000001);
      }
      /**
       * <code>optional string name = 1;</code>
       */
      public java.lang.String getName() {
        java.lang.Object ref = name_;
        if (!(ref instanceof java.lang.String)) {
          java.lang.String s = ((com.google.protobuf.ByteString) ref)
              .toStringUtf8();
          name_ = s;
          return s;
        } else {
          return (java.lang.String) ref;
        }
      }
      /**
       * <code>optional string name = 1;</code>
       */
      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;
        }
      }
      /**
       * <code>optional string name = 1;</code>
       */
      public Builder setName(
          java.lang.String value) {
        if (value == null) {
    throw new NullPointerException();
  }
  bitField0_ |= 0x00000001;
        name_ = value;
        onChanged();
        return this;
      }
      /**
       * <code>optional string name = 1;</code>
       */
      public Builder clearName() {
        bitField0_ = (bitField0_ & ~0x00000001);
        name_ = getDefaultInstance().getName();
        onChanged();
        return this;
      }
      /**
       * <code>optional string name = 1;</code>
       */
      public Builder setNameBytes(
          com.google.protobuf.ByteString value) {
        if (value == null) {
    throw new NullPointerException();
  }
  bitField0_ |= 0x00000001;
        name_ = value;
        onChanged();
        return this;
      }

      // optional string idNum = 2;
      private java.lang.Object idNum_ = "";
      /**
       * <code>optional string idNum = 2;</code>
       */
      public boolean hasIdNum() {
        return ((bitField0_ & 0x00000002) == 0x00000002);
      }
      /**
       * <code>optional string idNum = 2;</code>
       */
      public java.lang.String getIdNum() {
        java.lang.Object ref = idNum_;
        if (!(ref instanceof java.lang.String)) {
          java.lang.String s = ((com.google.protobuf.ByteString) ref)
              .toStringUtf8();
          idNum_ = s;
          return s;
        } else {
          return (java.lang.String) ref;
        }
      }
      /**
       * <code>optional string idNum = 2;</code>
       */
      public com.google.protobuf.ByteString
          getIdNumBytes() {
        java.lang.Object ref = idNum_;
        if (ref instanceof String) {
          com.google.protobuf.ByteString b = 
              com.google.protobuf.ByteString.copyFromUtf8(
                  (java.lang.String) ref);
          idNum_ = b;
          return b;
        } else {
          return (com.google.protobuf.ByteString) ref;
        }
      }
      /**
       * <code>optional string idNum = 2;</code>
       */
      public Builder setIdNum(
          java.lang.String value) {
        if (value == null) {
    throw new NullPointerException();
  }
  bitField0_ |= 0x00000002;
        idNum_ = value;
        onChanged();
        return this;
      }
      /**
       * <code>optional string idNum = 2;</code>
       */
      public Builder clearIdNum() {
        bitField0_ = (bitField0_ & ~0x00000002);
        idNum_ = getDefaultInstance().getIdNum();
        onChanged();
        return this;
      }
      /**
       * <code>optional string idNum = 2;</code>
       */
      public Builder setIdNumBytes(
          com.google.protobuf.ByteString value) {
        if (value == null) {
    throw new NullPointerException();
  }
  bitField0_ |= 0x00000002;
        idNum_ = value;
        onChanged();
        return this;
      }

      // optional .Address address = 3;
      private com.test.protocol.AddressProto.Address address_ = com.test.protocol.AddressProto.Address.getDefaultInstance();
      private com.google.protobuf.SingleFieldBuilder<
          com.test.protocol.AddressProto.Address, com.test.protocol.AddressProto.Address.Builder, com.test.protocol.AddressProto.AddressOrBuilder> addressBuilder_;
      /**
       * <code>optional .Address address = 3;</code>
       */
      public boolean hasAddress() {
        return ((bitField0_ & 0x00000004) == 0x00000004);
      }
      /**
       * <code>optional .Address address = 3;</code>
       */
      public com.test.protocol.AddressProto.Address getAddress() {
        if (addressBuilder_ == null) {
          return address_;
        } else {
          return addressBuilder_.getMessage();
        }
      }
      /**
       * <code>optional .Address address = 3;</code>
       */
      public Builder setAddress(com.test.protocol.AddressProto.Address value) {
        if (addressBuilder_ == null) {
          if (value == null) {
            throw new NullPointerException();
          }
          address_ = value;
          onChanged();
        } else {
          addressBuilder_.setMessage(value);
        }
        bitField0_ |= 0x00000004;
        return this;
      }
      /**
       * <code>optional .Address address = 3;</code>
       */
      public Builder setAddress(
          com.test.protocol.AddressProto.Address.Builder builderForValue) {
        if (addressBuilder_ == null) {
          address_ = builderForValue.build();
          onChanged();
        } else {
          addressBuilder_.setMessage(builderForValue.build());
        }
        bitField0_ |= 0x00000004;
        return this;
      }
      /**
       * <code>optional .Address address = 3;</code>
       */
      public Builder mergeAddress(com.test.protocol.AddressProto.Address value) {
        if (addressBuilder_ == null) {
          if (((bitField0_ & 0x00000004) == 0x00000004) &&
              address_ != com.test.protocol.AddressProto.Address.getDefaultInstance()) {
            address_ =
              com.test.protocol.AddressProto.Address.newBuilder(address_).mergeFrom(value).buildPartial();
          } else {
            address_ = value;
          }
          onChanged();
        } else {
          addressBuilder_.mergeFrom(value);
        }
        bitField0_ |= 0x00000004;
        return this;
      }
      /**
       * <code>optional .Address address = 3;</code>
       */
      public Builder clearAddress() {
        if (addressBuilder_ == null) {
          address_ = com.test.protocol.AddressProto.Address.getDefaultInstance();
          onChanged();
        } else {
          addressBuilder_.clear();
        }
        bitField0_ = (bitField0_ & ~0x00000004);
        return this;
      }
      /**
       * <code>optional .Address address = 3;</code>
       */
      public com.test.protocol.AddressProto.Address.Builder getAddressBuilder() {
        bitField0_ |= 0x00000004;
        onChanged();
        return getAddressFieldBuilder().getBuilder();
      }
      /**
       * <code>optional .Address address = 3;</code>
       */
      public com.test.protocol.AddressProto.AddressOrBuilder getAddressOrBuilder() {
        if (addressBuilder_ != null) {
          return addressBuilder_.getMessageOrBuilder();
        } else {
          return address_;
        }
      }
      /**
       * <code>optional .Address address = 3;</code>
       */
      private com.google.protobuf.SingleFieldBuilder<
          com.test.protocol.AddressProto.Address, com.test.protocol.AddressProto.Address.Builder, com.test.protocol.AddressProto.AddressOrBuilder> 
          getAddressFieldBuilder() {
        if (addressBuilder_ == null) {
          addressBuilder_ = new com.google.protobuf.SingleFieldBuilder<
              com.test.protocol.AddressProto.Address, com.test.protocol.AddressProto.Address.Builder, com.test.protocol.AddressProto.AddressOrBuilder>(
                  address_,
                  getParentForChildren(),
                  isClean());
          address_ = null;
        }
        return addressBuilder_;
      }

      // @@protoc_insertion_point(builder_scope:Person)
    }

    static {
      defaultInstance = new Person(true);
      defaultInstance.initFields();
    }

    // @@protoc_insertion_point(class_scope:Person)
  }

  private static com.google.protobuf.Descriptors.Descriptor
    internal_static_Person_descriptor;
  private static
    com.google.protobuf.GeneratedMessage.FieldAccessorTable
      internal_static_Person_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\014person.proto\032\naddr.proto\"@\n\006Person\022\014\n\004" +
      "name\030\001 \001(\t\022\r\n\005idNum\030\002 \001(\t\022\031\n\007address\030\003 \001" +
      "(\0132\010.AddressB \n\021com.test.protocolB\013Perso" +
      "nProto"
    };
    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
      new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
        public com.google.protobuf.ExtensionRegistry assignDescriptors(
            com.google.protobuf.Descriptors.FileDescriptor root) {
          descriptor = root;
          internal_static_Person_descriptor =
            getDescriptor().getMessageTypes().get(0);
          internal_static_Person_fieldAccessorTable = new
            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
              internal_static_Person_descriptor,
              new java.lang.String[] { "Name", "IdNum", "Address", });
          return null;
        }
      };
    com.google.protobuf.Descriptors.FileDescriptor
      .internalBuildGeneratedFileFrom(descriptorData,
        new com.google.protobuf.Descriptors.FileDescriptor[] {
          com.test.protocol.AddressProto.getDescriptor(),
        }, assigner);
  }

  // @@protoc_insertion_point(outer_class_scope)
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值