/*
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/asset/v1/assets.proto

package com.google.cloud.asset.v1;

/**
 *
 *
 * <pre>
 * An asset identifier in Google Cloud which contains its name, type and
 * ancestors. An asset can be any resource in the Google Cloud [resource
 * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
 * a resource outside the Google Cloud resource hierarchy (such as Google
 * Kubernetes Engine clusters and objects), or a policy (e.g. IAM policy).
 * See [Supported asset
 * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
 * for more information.
 * </pre>
 *
 * Protobuf type {@code google.cloud.asset.v1.RelatedAsset}
 */
public final class RelatedAsset extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.cloud.asset.v1.RelatedAsset)
    RelatedAssetOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use RelatedAsset.newBuilder() to construct.
  private RelatedAsset(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private RelatedAsset() {
    asset_ = "";
    assetType_ = "";
    ancestors_ = com.google.protobuf.LazyStringArrayList.EMPTY;
    relationshipType_ = "";
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
    return new RelatedAsset();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.cloud.asset.v1.AssetProto
        .internal_static_google_cloud_asset_v1_RelatedAsset_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.asset.v1.AssetProto
        .internal_static_google_cloud_asset_v1_RelatedAsset_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.asset.v1.RelatedAsset.class,
            com.google.cloud.asset.v1.RelatedAsset.Builder.class);
  }

  public static final int ASSET_FIELD_NUMBER = 1;

  @SuppressWarnings("serial")
  private volatile java.lang.Object asset_ = "";
  /**
   *
   *
   * <pre>
   * The full name of the asset. Example:
   * `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`
   * See [Resource
   * names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
   * for more information.
   * </pre>
   *
   * <code>string asset = 1 [(.google.api.resource_reference) = { ... }</code>
   *
   * @return The asset.
   */
  @java.lang.Override
  public java.lang.String getAsset() {
    java.lang.Object ref = asset_;
    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();
      asset_ = s;
      return s;
    }
  }
  /**
   *
   *
   * <pre>
   * The full name of the asset. Example:
   * `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`
   * See [Resource
   * names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
   * for more information.
   * </pre>
   *
   * <code>string asset = 1 [(.google.api.resource_reference) = { ... }</code>
   *
   * @return The bytes for asset.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getAssetBytes() {
    java.lang.Object ref = asset_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      asset_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int ASSET_TYPE_FIELD_NUMBER = 2;

  @SuppressWarnings("serial")
  private volatile java.lang.Object assetType_ = "";
  /**
   *
   *
   * <pre>
   * The type of the asset. Example: `compute.googleapis.com/Disk`
   * See [Supported asset
   * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
   * for more information.
   * </pre>
   *
   * <code>string asset_type = 2;</code>
   *
   * @return The assetType.
   */
  @java.lang.Override
  public java.lang.String getAssetType() {
    java.lang.Object ref = assetType_;
    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();
      assetType_ = s;
      return s;
    }
  }
  /**
   *
   *
   * <pre>
   * The type of the asset. Example: `compute.googleapis.com/Disk`
   * See [Supported asset
   * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
   * for more information.
   * </pre>
   *
   * <code>string asset_type = 2;</code>
   *
   * @return The bytes for assetType.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getAssetTypeBytes() {
    java.lang.Object ref = assetType_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      assetType_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int ANCESTORS_FIELD_NUMBER = 3;

  @SuppressWarnings("serial")
  private com.google.protobuf.LazyStringList ancestors_;
  /**
   *
   *
   * <pre>
   * The ancestors of an asset in Google Cloud [resource
   * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
   * represented as a list of relative resource names. An ancestry path starts
   * with the closest ancestor in the hierarchy and ends at root.
   * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
   * </pre>
   *
   * <code>repeated string ancestors = 3;</code>
   *
   * @return A list containing the ancestors.
   */
  public com.google.protobuf.ProtocolStringList getAncestorsList() {
    return ancestors_;
  }
  /**
   *
   *
   * <pre>
   * The ancestors of an asset in Google Cloud [resource
   * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
   * represented as a list of relative resource names. An ancestry path starts
   * with the closest ancestor in the hierarchy and ends at root.
   * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
   * </pre>
   *
   * <code>repeated string ancestors = 3;</code>
   *
   * @return The count of ancestors.
   */
  public int getAncestorsCount() {
    return ancestors_.size();
  }
  /**
   *
   *
   * <pre>
   * The ancestors of an asset in Google Cloud [resource
   * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
   * represented as a list of relative resource names. An ancestry path starts
   * with the closest ancestor in the hierarchy and ends at root.
   * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
   * </pre>
   *
   * <code>repeated string ancestors = 3;</code>
   *
   * @param index The index of the element to return.
   * @return The ancestors at the given index.
   */
  public java.lang.String getAncestors(int index) {
    return ancestors_.get(index);
  }
  /**
   *
   *
   * <pre>
   * The ancestors of an asset in Google Cloud [resource
   * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
   * represented as a list of relative resource names. An ancestry path starts
   * with the closest ancestor in the hierarchy and ends at root.
   * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
   * </pre>
   *
   * <code>repeated string ancestors = 3;</code>
   *
   * @param index The index of the value to return.
   * @return The bytes of the ancestors at the given index.
   */
  public com.google.protobuf.ByteString getAncestorsBytes(int index) {
    return ancestors_.getByteString(index);
  }

  public static final int RELATIONSHIP_TYPE_FIELD_NUMBER = 4;

  @SuppressWarnings("serial")
  private volatile java.lang.Object relationshipType_ = "";
  /**
   *
   *
   * <pre>
   * The unique identifier of the relationship type. Example:
   * `INSTANCE_TO_INSTANCEGROUP`
   * </pre>
   *
   * <code>string relationship_type = 4;</code>
   *
   * @return The relationshipType.
   */
  @java.lang.Override
  public java.lang.String getRelationshipType() {
    java.lang.Object ref = relationshipType_;
    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();
      relationshipType_ = s;
      return s;
    }
  }
  /**
   *
   *
   * <pre>
   * The unique identifier of the relationship type. Example:
   * `INSTANCE_TO_INSTANCEGROUP`
   * </pre>
   *
   * <code>string relationship_type = 4;</code>
   *
   * @return The bytes for relationshipType.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getRelationshipTypeBytes() {
    java.lang.Object ref = relationshipType_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      relationshipType_ = 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;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(asset_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, asset_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(assetType_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 2, assetType_);
    }
    for (int i = 0; i < ancestors_.size(); i++) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 3, ancestors_.getRaw(i));
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(relationshipType_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 4, relationshipType_);
    }
    getUnknownFields().writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(asset_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, asset_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(assetType_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, assetType_);
    }
    {
      int dataSize = 0;
      for (int i = 0; i < ancestors_.size(); i++) {
        dataSize += computeStringSizeNoTag(ancestors_.getRaw(i));
      }
      size += dataSize;
      size += 1 * getAncestorsList().size();
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(relationshipType_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, relationshipType_);
    }
    size += getUnknownFields().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.google.cloud.asset.v1.RelatedAsset)) {
      return super.equals(obj);
    }
    com.google.cloud.asset.v1.RelatedAsset other = (com.google.cloud.asset.v1.RelatedAsset) obj;

    if (!getAsset().equals(other.getAsset())) return false;
    if (!getAssetType().equals(other.getAssetType())) return false;
    if (!getAncestorsList().equals(other.getAncestorsList())) return false;
    if (!getRelationshipType().equals(other.getRelationshipType())) return false;
    if (!getUnknownFields().equals(other.getUnknownFields())) 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) + ASSET_FIELD_NUMBER;
    hash = (53 * hash) + getAsset().hashCode();
    hash = (37 * hash) + ASSET_TYPE_FIELD_NUMBER;
    hash = (53 * hash) + getAssetType().hashCode();
    if (getAncestorsCount() > 0) {
      hash = (37 * hash) + ANCESTORS_FIELD_NUMBER;
      hash = (53 * hash) + getAncestorsList().hashCode();
    }
    hash = (37 * hash) + RELATIONSHIP_TYPE_FIELD_NUMBER;
    hash = (53 * hash) + getRelationshipType().hashCode();
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.asset.v1.RelatedAsset parseFrom(java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.asset.v1.RelatedAsset parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.asset.v1.RelatedAsset parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.asset.v1.RelatedAsset parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.asset.v1.RelatedAsset parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.asset.v1.RelatedAsset parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.asset.v1.RelatedAsset parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.asset.v1.RelatedAsset 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.google.cloud.asset.v1.RelatedAsset parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.cloud.asset.v1.RelatedAsset 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.google.cloud.asset.v1.RelatedAsset parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.asset.v1.RelatedAsset 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.google.cloud.asset.v1.RelatedAsset 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;
  }
  /**
   *
   *
   * <pre>
   * An asset identifier in Google Cloud which contains its name, type and
   * ancestors. An asset can be any resource in the Google Cloud [resource
   * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
   * a resource outside the Google Cloud resource hierarchy (such as Google
   * Kubernetes Engine clusters and objects), or a policy (e.g. IAM policy).
   * See [Supported asset
   * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
   * for more information.
   * </pre>
   *
   * Protobuf type {@code google.cloud.asset.v1.RelatedAsset}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.cloud.asset.v1.RelatedAsset)
      com.google.cloud.asset.v1.RelatedAssetOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.cloud.asset.v1.AssetProto
          .internal_static_google_cloud_asset_v1_RelatedAsset_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.asset.v1.AssetProto
          .internal_static_google_cloud_asset_v1_RelatedAsset_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.asset.v1.RelatedAsset.class,
              com.google.cloud.asset.v1.RelatedAsset.Builder.class);
    }

    // Construct using com.google.cloud.asset.v1.RelatedAsset.newBuilder()
    private Builder() {}

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      bitField0_ = 0;
      asset_ = "";
      assetType_ = "";
      ancestors_ = com.google.protobuf.LazyStringArrayList.EMPTY;
      bitField0_ = (bitField0_ & ~0x00000004);
      relationshipType_ = "";
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.cloud.asset.v1.AssetProto
          .internal_static_google_cloud_asset_v1_RelatedAsset_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.asset.v1.RelatedAsset getDefaultInstanceForType() {
      return com.google.cloud.asset.v1.RelatedAsset.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.cloud.asset.v1.RelatedAsset build() {
      com.google.cloud.asset.v1.RelatedAsset result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.cloud.asset.v1.RelatedAsset buildPartial() {
      com.google.cloud.asset.v1.RelatedAsset result =
          new com.google.cloud.asset.v1.RelatedAsset(this);
      buildPartialRepeatedFields(result);
      if (bitField0_ != 0) {
        buildPartial0(result);
      }
      onBuilt();
      return result;
    }

    private void buildPartialRepeatedFields(com.google.cloud.asset.v1.RelatedAsset result) {
      if (((bitField0_ & 0x00000004) != 0)) {
        ancestors_ = ancestors_.getUnmodifiableView();
        bitField0_ = (bitField0_ & ~0x00000004);
      }
      result.ancestors_ = ancestors_;
    }

    private void buildPartial0(com.google.cloud.asset.v1.RelatedAsset result) {
      int from_bitField0_ = bitField0_;
      if (((from_bitField0_ & 0x00000001) != 0)) {
        result.asset_ = asset_;
      }
      if (((from_bitField0_ & 0x00000002) != 0)) {
        result.assetType_ = assetType_;
      }
      if (((from_bitField0_ & 0x00000008) != 0)) {
        result.relationshipType_ = relationshipType_;
      }
    }

    @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.google.cloud.asset.v1.RelatedAsset) {
        return mergeFrom((com.google.cloud.asset.v1.RelatedAsset) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.asset.v1.RelatedAsset other) {
      if (other == com.google.cloud.asset.v1.RelatedAsset.getDefaultInstance()) return this;
      if (!other.getAsset().isEmpty()) {
        asset_ = other.asset_;
        bitField0_ |= 0x00000001;
        onChanged();
      }
      if (!other.getAssetType().isEmpty()) {
        assetType_ = other.assetType_;
        bitField0_ |= 0x00000002;
        onChanged();
      }
      if (!other.ancestors_.isEmpty()) {
        if (ancestors_.isEmpty()) {
          ancestors_ = other.ancestors_;
          bitField0_ = (bitField0_ & ~0x00000004);
        } else {
          ensureAncestorsIsMutable();
          ancestors_.addAll(other.ancestors_);
        }
        onChanged();
      }
      if (!other.getRelationshipType().isEmpty()) {
        relationshipType_ = other.relationshipType_;
        bitField0_ |= 0x00000008;
        onChanged();
      }
      this.mergeUnknownFields(other.getUnknownFields());
      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 {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 10:
              {
                asset_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000001;
                break;
              } // case 10
            case 18:
              {
                assetType_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000002;
                break;
              } // case 18
            case 26:
              {
                java.lang.String s = input.readStringRequireUtf8();
                ensureAncestorsIsMutable();
                ancestors_.add(s);
                break;
              } // case 26
            case 34:
              {
                relationshipType_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000008;
                break;
              } // case 34
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int bitField0_;

    private java.lang.Object asset_ = "";
    /**
     *
     *
     * <pre>
     * The full name of the asset. Example:
     * `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`
     * See [Resource
     * names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
     * for more information.
     * </pre>
     *
     * <code>string asset = 1 [(.google.api.resource_reference) = { ... }</code>
     *
     * @return The asset.
     */
    public java.lang.String getAsset() {
      java.lang.Object ref = asset_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        asset_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The full name of the asset. Example:
     * `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`
     * See [Resource
     * names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
     * for more information.
     * </pre>
     *
     * <code>string asset = 1 [(.google.api.resource_reference) = { ... }</code>
     *
     * @return The bytes for asset.
     */
    public com.google.protobuf.ByteString getAssetBytes() {
      java.lang.Object ref = asset_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        asset_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The full name of the asset. Example:
     * `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`
     * See [Resource
     * names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
     * for more information.
     * </pre>
     *
     * <code>string asset = 1 [(.google.api.resource_reference) = { ... }</code>
     *
     * @param value The asset to set.
     * @return This builder for chaining.
     */
    public Builder setAsset(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      asset_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The full name of the asset. Example:
     * `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`
     * See [Resource
     * names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
     * for more information.
     * </pre>
     *
     * <code>string asset = 1 [(.google.api.resource_reference) = { ... }</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearAsset() {
      asset_ = getDefaultInstance().getAsset();
      bitField0_ = (bitField0_ & ~0x00000001);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The full name of the asset. Example:
     * `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`
     * See [Resource
     * names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
     * for more information.
     * </pre>
     *
     * <code>string asset = 1 [(.google.api.resource_reference) = { ... }</code>
     *
     * @param value The bytes for asset to set.
     * @return This builder for chaining.
     */
    public Builder setAssetBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      asset_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }

    private java.lang.Object assetType_ = "";
    /**
     *
     *
     * <pre>
     * The type of the asset. Example: `compute.googleapis.com/Disk`
     * See [Supported asset
     * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
     * for more information.
     * </pre>
     *
     * <code>string asset_type = 2;</code>
     *
     * @return The assetType.
     */
    public java.lang.String getAssetType() {
      java.lang.Object ref = assetType_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        assetType_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The type of the asset. Example: `compute.googleapis.com/Disk`
     * See [Supported asset
     * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
     * for more information.
     * </pre>
     *
     * <code>string asset_type = 2;</code>
     *
     * @return The bytes for assetType.
     */
    public com.google.protobuf.ByteString getAssetTypeBytes() {
      java.lang.Object ref = assetType_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        assetType_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The type of the asset. Example: `compute.googleapis.com/Disk`
     * See [Supported asset
     * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
     * for more information.
     * </pre>
     *
     * <code>string asset_type = 2;</code>
     *
     * @param value The assetType to set.
     * @return This builder for chaining.
     */
    public Builder setAssetType(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      assetType_ = value;
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The type of the asset. Example: `compute.googleapis.com/Disk`
     * See [Supported asset
     * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
     * for more information.
     * </pre>
     *
     * <code>string asset_type = 2;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearAssetType() {
      assetType_ = getDefaultInstance().getAssetType();
      bitField0_ = (bitField0_ & ~0x00000002);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The type of the asset. Example: `compute.googleapis.com/Disk`
     * See [Supported asset
     * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
     * for more information.
     * </pre>
     *
     * <code>string asset_type = 2;</code>
     *
     * @param value The bytes for assetType to set.
     * @return This builder for chaining.
     */
    public Builder setAssetTypeBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      assetType_ = value;
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }

    private com.google.protobuf.LazyStringList ancestors_ =
        com.google.protobuf.LazyStringArrayList.EMPTY;

    private void ensureAncestorsIsMutable() {
      if (!((bitField0_ & 0x00000004) != 0)) {
        ancestors_ = new com.google.protobuf.LazyStringArrayList(ancestors_);
        bitField0_ |= 0x00000004;
      }
    }
    /**
     *
     *
     * <pre>
     * The ancestors of an asset in Google Cloud [resource
     * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
     * represented as a list of relative resource names. An ancestry path starts
     * with the closest ancestor in the hierarchy and ends at root.
     * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
     * </pre>
     *
     * <code>repeated string ancestors = 3;</code>
     *
     * @return A list containing the ancestors.
     */
    public com.google.protobuf.ProtocolStringList getAncestorsList() {
      return ancestors_.getUnmodifiableView();
    }
    /**
     *
     *
     * <pre>
     * The ancestors of an asset in Google Cloud [resource
     * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
     * represented as a list of relative resource names. An ancestry path starts
     * with the closest ancestor in the hierarchy and ends at root.
     * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
     * </pre>
     *
     * <code>repeated string ancestors = 3;</code>
     *
     * @return The count of ancestors.
     */
    public int getAncestorsCount() {
      return ancestors_.size();
    }
    /**
     *
     *
     * <pre>
     * The ancestors of an asset in Google Cloud [resource
     * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
     * represented as a list of relative resource names. An ancestry path starts
     * with the closest ancestor in the hierarchy and ends at root.
     * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
     * </pre>
     *
     * <code>repeated string ancestors = 3;</code>
     *
     * @param index The index of the element to return.
     * @return The ancestors at the given index.
     */
    public java.lang.String getAncestors(int index) {
      return ancestors_.get(index);
    }
    /**
     *
     *
     * <pre>
     * The ancestors of an asset in Google Cloud [resource
     * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
     * represented as a list of relative resource names. An ancestry path starts
     * with the closest ancestor in the hierarchy and ends at root.
     * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
     * </pre>
     *
     * <code>repeated string ancestors = 3;</code>
     *
     * @param index The index of the value to return.
     * @return The bytes of the ancestors at the given index.
     */
    public com.google.protobuf.ByteString getAncestorsBytes(int index) {
      return ancestors_.getByteString(index);
    }
    /**
     *
     *
     * <pre>
     * The ancestors of an asset in Google Cloud [resource
     * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
     * represented as a list of relative resource names. An ancestry path starts
     * with the closest ancestor in the hierarchy and ends at root.
     * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
     * </pre>
     *
     * <code>repeated string ancestors = 3;</code>
     *
     * @param index The index to set the value at.
     * @param value The ancestors to set.
     * @return This builder for chaining.
     */
    public Builder setAncestors(int index, java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      ensureAncestorsIsMutable();
      ancestors_.set(index, value);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The ancestors of an asset in Google Cloud [resource
     * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
     * represented as a list of relative resource names. An ancestry path starts
     * with the closest ancestor in the hierarchy and ends at root.
     * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
     * </pre>
     *
     * <code>repeated string ancestors = 3;</code>
     *
     * @param value The ancestors to add.
     * @return This builder for chaining.
     */
    public Builder addAncestors(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      ensureAncestorsIsMutable();
      ancestors_.add(value);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The ancestors of an asset in Google Cloud [resource
     * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
     * represented as a list of relative resource names. An ancestry path starts
     * with the closest ancestor in the hierarchy and ends at root.
     * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
     * </pre>
     *
     * <code>repeated string ancestors = 3;</code>
     *
     * @param values The ancestors to add.
     * @return This builder for chaining.
     */
    public Builder addAllAncestors(java.lang.Iterable<java.lang.String> values) {
      ensureAncestorsIsMutable();
      com.google.protobuf.AbstractMessageLite.Builder.addAll(values, ancestors_);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The ancestors of an asset in Google Cloud [resource
     * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
     * represented as a list of relative resource names. An ancestry path starts
     * with the closest ancestor in the hierarchy and ends at root.
     * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
     * </pre>
     *
     * <code>repeated string ancestors = 3;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearAncestors() {
      ancestors_ = com.google.protobuf.LazyStringArrayList.EMPTY;
      bitField0_ = (bitField0_ & ~0x00000004);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The ancestors of an asset in Google Cloud [resource
     * hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
     * represented as a list of relative resource names. An ancestry path starts
     * with the closest ancestor in the hierarchy and ends at root.
     * Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
     * </pre>
     *
     * <code>repeated string ancestors = 3;</code>
     *
     * @param value The bytes of the ancestors to add.
     * @return This builder for chaining.
     */
    public Builder addAncestorsBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      ensureAncestorsIsMutable();
      ancestors_.add(value);
      onChanged();
      return this;
    }

    private java.lang.Object relationshipType_ = "";
    /**
     *
     *
     * <pre>
     * The unique identifier of the relationship type. Example:
     * `INSTANCE_TO_INSTANCEGROUP`
     * </pre>
     *
     * <code>string relationship_type = 4;</code>
     *
     * @return The relationshipType.
     */
    public java.lang.String getRelationshipType() {
      java.lang.Object ref = relationshipType_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        relationshipType_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The unique identifier of the relationship type. Example:
     * `INSTANCE_TO_INSTANCEGROUP`
     * </pre>
     *
     * <code>string relationship_type = 4;</code>
     *
     * @return The bytes for relationshipType.
     */
    public com.google.protobuf.ByteString getRelationshipTypeBytes() {
      java.lang.Object ref = relationshipType_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        relationshipType_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * The unique identifier of the relationship type. Example:
     * `INSTANCE_TO_INSTANCEGROUP`
     * </pre>
     *
     * <code>string relationship_type = 4;</code>
     *
     * @param value The relationshipType to set.
     * @return This builder for chaining.
     */
    public Builder setRelationshipType(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      relationshipType_ = value;
      bitField0_ |= 0x00000008;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The unique identifier of the relationship type. Example:
     * `INSTANCE_TO_INSTANCEGROUP`
     * </pre>
     *
     * <code>string relationship_type = 4;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearRelationshipType() {
      relationshipType_ = getDefaultInstance().getRelationshipType();
      bitField0_ = (bitField0_ & ~0x00000008);
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The unique identifier of the relationship type. Example:
     * `INSTANCE_TO_INSTANCEGROUP`
     * </pre>
     *
     * <code>string relationship_type = 4;</code>
     *
     * @param value The bytes for relationshipType to set.
     * @return This builder for chaining.
     */
    public Builder setRelationshipTypeBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      relationshipType_ = value;
      bitField0_ |= 0x00000008;
      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:google.cloud.asset.v1.RelatedAsset)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.asset.v1.RelatedAsset)
  private static final com.google.cloud.asset.v1.RelatedAsset DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.cloud.asset.v1.RelatedAsset();
  }

  public static com.google.cloud.asset.v1.RelatedAsset getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<RelatedAsset> PARSER =
      new com.google.protobuf.AbstractParser<RelatedAsset>() {
        @java.lang.Override
        public RelatedAsset parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
          } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(builder.buildPartial());
          } catch (com.google.protobuf.UninitializedMessageException e) {
            throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
          } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(e)
                .setUnfinishedMessage(builder.buildPartial());
          }
          return builder.buildPartial();
        }
      };

  public static com.google.protobuf.Parser<RelatedAsset> parser() {
    return PARSER;
  }

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

  @java.lang.Override
  public com.google.cloud.asset.v1.RelatedAsset getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}
