/*
 * Copyright 2026 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!
// NO CHECKED-IN PROTOBUF GENCODE
// source: google/api/policy.proto
// Protobuf Java Version: 4.33.2

package com.google.api;

/**
 *
 *
 * <pre>
 * Defines policies applying to an RPC method.
 * </pre>
 *
 * Protobuf type {@code google.api.MethodPolicy}
 */
@com.google.protobuf.Generated
public final class MethodPolicy extends com.google.protobuf.GeneratedMessage
    implements
    // @@protoc_insertion_point(message_implements:google.api.MethodPolicy)
    MethodPolicyOrBuilder {
  private static final long serialVersionUID = 0L;

  static {
    com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(
        com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC,
        /* major= */ 4,
        /* minor= */ 33,
        /* patch= */ 2,
        /* suffix= */ "",
        "MethodPolicy");
  }

  // Use MethodPolicy.newBuilder() to construct.
  private MethodPolicy(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
    super(builder);
  }

  private MethodPolicy() {
    selector_ = "";
    requestPolicies_ = java.util.Collections.emptyList();
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.api.MethodPolicy.class, com.google.api.MethodPolicy.Builder.class);
  }

  public static final int SELECTOR_FIELD_NUMBER = 9;

  @SuppressWarnings("serial")
  private volatile java.lang.Object selector_ = "";

  /**
   *
   *
   * <pre>
   * Selects a method to which these policies should be enforced, for example,
   * "google.pubsub.v1.Subscriber.CreateSubscription".
   *
   * Refer to [selector][google.api.DocumentationRule.selector] for syntax
   * details.
   *
   * NOTE: This field must not be set in the proto annotation. It will be
   * automatically filled by the service config compiler .
   * </pre>
   *
   * <code>string selector = 9;</code>
   *
   * @return The selector.
   */
  @java.lang.Override
  public java.lang.String getSelector() {
    java.lang.Object ref = selector_;
    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();
      selector_ = s;
      return s;
    }
  }

  /**
   *
   *
   * <pre>
   * Selects a method to which these policies should be enforced, for example,
   * "google.pubsub.v1.Subscriber.CreateSubscription".
   *
   * Refer to [selector][google.api.DocumentationRule.selector] for syntax
   * details.
   *
   * NOTE: This field must not be set in the proto annotation. It will be
   * automatically filled by the service config compiler .
   * </pre>
   *
   * <code>string selector = 9;</code>
   *
   * @return The bytes for selector.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getSelectorBytes() {
    java.lang.Object ref = selector_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      selector_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int REQUEST_POLICIES_FIELD_NUMBER = 2;

  @SuppressWarnings("serial")
  private java.util.List<com.google.api.FieldPolicy> requestPolicies_;

  /**
   *
   *
   * <pre>
   * Policies that are applicable to the request message.
   * </pre>
   *
   * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
   */
  @java.lang.Override
  public java.util.List<com.google.api.FieldPolicy> getRequestPoliciesList() {
    return requestPolicies_;
  }

  /**
   *
   *
   * <pre>
   * Policies that are applicable to the request message.
   * </pre>
   *
   * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
   */
  @java.lang.Override
  public java.util.List<? extends com.google.api.FieldPolicyOrBuilder>
      getRequestPoliciesOrBuilderList() {
    return requestPolicies_;
  }

  /**
   *
   *
   * <pre>
   * Policies that are applicable to the request message.
   * </pre>
   *
   * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
   */
  @java.lang.Override
  public int getRequestPoliciesCount() {
    return requestPolicies_.size();
  }

  /**
   *
   *
   * <pre>
   * Policies that are applicable to the request message.
   * </pre>
   *
   * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
   */
  @java.lang.Override
  public com.google.api.FieldPolicy getRequestPolicies(int index) {
    return requestPolicies_.get(index);
  }

  /**
   *
   *
   * <pre>
   * Policies that are applicable to the request message.
   * </pre>
   *
   * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
   */
  @java.lang.Override
  public com.google.api.FieldPolicyOrBuilder getRequestPoliciesOrBuilder(int index) {
    return requestPolicies_.get(index);
  }

  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 {
    for (int i = 0; i < requestPolicies_.size(); i++) {
      output.writeMessage(2, requestPolicies_.get(i));
    }
    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(selector_)) {
      com.google.protobuf.GeneratedMessage.writeString(output, 9, selector_);
    }
    getUnknownFields().writeTo(output);
  }

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

    size = 0;
    for (int i = 0; i < requestPolicies_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, requestPolicies_.get(i));
    }
    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(selector_)) {
      size += com.google.protobuf.GeneratedMessage.computeStringSize(9, selector_);
    }
    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.api.MethodPolicy)) {
      return super.equals(obj);
    }
    com.google.api.MethodPolicy other = (com.google.api.MethodPolicy) obj;

    if (!getSelector().equals(other.getSelector())) return false;
    if (!getRequestPoliciesList().equals(other.getRequestPoliciesList())) 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) + SELECTOR_FIELD_NUMBER;
    hash = (53 * hash) + getSelector().hashCode();
    if (getRequestPoliciesCount() > 0) {
      hash = (37 * hash) + REQUEST_POLICIES_FIELD_NUMBER;
      hash = (53 * hash) + getRequestPoliciesList().hashCode();
    }
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.api.MethodPolicy parseFrom(java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.api.MethodPolicy parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.api.MethodPolicy parseFrom(com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.api.MethodPolicy 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.api.MethodPolicy parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.api.MethodPolicy parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.api.MethodPolicy parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input);
  }

  public static com.google.api.MethodPolicy parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.api.MethodPolicy parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.api.MethodPolicy parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.api.MethodPolicy parseFrom(com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input);
  }

  public static com.google.api.MethodPolicy parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.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.api.MethodPolicy 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.GeneratedMessage.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }

  /**
   *
   *
   * <pre>
   * Defines policies applying to an RPC method.
   * </pre>
   *
   * Protobuf type {@code google.api.MethodPolicy}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.api.MethodPolicy)
      com.google.api.MethodPolicyOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.api.MethodPolicy.class, com.google.api.MethodPolicy.Builder.class);
    }

    // Construct using com.google.api.MethodPolicy.newBuilder()
    private Builder() {}

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

    @java.lang.Override
    public Builder clear() {
      super.clear();
      bitField0_ = 0;
      selector_ = "";
      if (requestPoliciesBuilder_ == null) {
        requestPolicies_ = java.util.Collections.emptyList();
      } else {
        requestPolicies_ = null;
        requestPoliciesBuilder_.clear();
      }
      bitField0_ = (bitField0_ & ~0x00000002);
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_descriptor;
    }

    @java.lang.Override
    public com.google.api.MethodPolicy getDefaultInstanceForType() {
      return com.google.api.MethodPolicy.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.api.MethodPolicy build() {
      com.google.api.MethodPolicy result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

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

    private void buildPartialRepeatedFields(com.google.api.MethodPolicy result) {
      if (requestPoliciesBuilder_ == null) {
        if (((bitField0_ & 0x00000002) != 0)) {
          requestPolicies_ = java.util.Collections.unmodifiableList(requestPolicies_);
          bitField0_ = (bitField0_ & ~0x00000002);
        }
        result.requestPolicies_ = requestPolicies_;
      } else {
        result.requestPolicies_ = requestPoliciesBuilder_.build();
      }
    }

    private void buildPartial0(com.google.api.MethodPolicy result) {
      int from_bitField0_ = bitField0_;
      if (((from_bitField0_ & 0x00000001) != 0)) {
        result.selector_ = selector_;
      }
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.api.MethodPolicy) {
        return mergeFrom((com.google.api.MethodPolicy) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.api.MethodPolicy other) {
      if (other == com.google.api.MethodPolicy.getDefaultInstance()) return this;
      if (!other.getSelector().isEmpty()) {
        selector_ = other.selector_;
        bitField0_ |= 0x00000001;
        onChanged();
      }
      if (requestPoliciesBuilder_ == null) {
        if (!other.requestPolicies_.isEmpty()) {
          if (requestPolicies_.isEmpty()) {
            requestPolicies_ = other.requestPolicies_;
            bitField0_ = (bitField0_ & ~0x00000002);
          } else {
            ensureRequestPoliciesIsMutable();
            requestPolicies_.addAll(other.requestPolicies_);
          }
          onChanged();
        }
      } else {
        if (!other.requestPolicies_.isEmpty()) {
          if (requestPoliciesBuilder_.isEmpty()) {
            requestPoliciesBuilder_.dispose();
            requestPoliciesBuilder_ = null;
            requestPolicies_ = other.requestPolicies_;
            bitField0_ = (bitField0_ & ~0x00000002);
            requestPoliciesBuilder_ =
                com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders
                    ? internalGetRequestPoliciesFieldBuilder()
                    : null;
          } else {
            requestPoliciesBuilder_.addAllMessages(other.requestPolicies_);
          }
        }
      }
      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 18:
              {
                com.google.api.FieldPolicy m =
                    input.readMessage(com.google.api.FieldPolicy.parser(), extensionRegistry);
                if (requestPoliciesBuilder_ == null) {
                  ensureRequestPoliciesIsMutable();
                  requestPolicies_.add(m);
                } else {
                  requestPoliciesBuilder_.addMessage(m);
                }
                break;
              } // case 18
            case 74:
              {
                selector_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000001;
                break;
              } // case 74
            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 selector_ = "";

    /**
     *
     *
     * <pre>
     * Selects a method to which these policies should be enforced, for example,
     * "google.pubsub.v1.Subscriber.CreateSubscription".
     *
     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
     * details.
     *
     * NOTE: This field must not be set in the proto annotation. It will be
     * automatically filled by the service config compiler .
     * </pre>
     *
     * <code>string selector = 9;</code>
     *
     * @return The selector.
     */
    public java.lang.String getSelector() {
      java.lang.Object ref = selector_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        selector_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }

    /**
     *
     *
     * <pre>
     * Selects a method to which these policies should be enforced, for example,
     * "google.pubsub.v1.Subscriber.CreateSubscription".
     *
     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
     * details.
     *
     * NOTE: This field must not be set in the proto annotation. It will be
     * automatically filled by the service config compiler .
     * </pre>
     *
     * <code>string selector = 9;</code>
     *
     * @return The bytes for selector.
     */
    public com.google.protobuf.ByteString getSelectorBytes() {
      java.lang.Object ref = selector_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        selector_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }

    /**
     *
     *
     * <pre>
     * Selects a method to which these policies should be enforced, for example,
     * "google.pubsub.v1.Subscriber.CreateSubscription".
     *
     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
     * details.
     *
     * NOTE: This field must not be set in the proto annotation. It will be
     * automatically filled by the service config compiler .
     * </pre>
     *
     * <code>string selector = 9;</code>
     *
     * @param value The selector to set.
     * @return This builder for chaining.
     */
    public Builder setSelector(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      selector_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Selects a method to which these policies should be enforced, for example,
     * "google.pubsub.v1.Subscriber.CreateSubscription".
     *
     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
     * details.
     *
     * NOTE: This field must not be set in the proto annotation. It will be
     * automatically filled by the service config compiler .
     * </pre>
     *
     * <code>string selector = 9;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearSelector() {
      selector_ = getDefaultInstance().getSelector();
      bitField0_ = (bitField0_ & ~0x00000001);
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Selects a method to which these policies should be enforced, for example,
     * "google.pubsub.v1.Subscriber.CreateSubscription".
     *
     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
     * details.
     *
     * NOTE: This field must not be set in the proto annotation. It will be
     * automatically filled by the service config compiler .
     * </pre>
     *
     * <code>string selector = 9;</code>
     *
     * @param value The bytes for selector to set.
     * @return This builder for chaining.
     */
    public Builder setSelectorBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      selector_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }

    private java.util.List<com.google.api.FieldPolicy> requestPolicies_ =
        java.util.Collections.emptyList();

    private void ensureRequestPoliciesIsMutable() {
      if (!((bitField0_ & 0x00000002) != 0)) {
        requestPolicies_ = new java.util.ArrayList<com.google.api.FieldPolicy>(requestPolicies_);
        bitField0_ |= 0x00000002;
      }
    }

    private com.google.protobuf.RepeatedFieldBuilder<
            com.google.api.FieldPolicy,
            com.google.api.FieldPolicy.Builder,
            com.google.api.FieldPolicyOrBuilder>
        requestPoliciesBuilder_;

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public java.util.List<com.google.api.FieldPolicy> getRequestPoliciesList() {
      if (requestPoliciesBuilder_ == null) {
        return java.util.Collections.unmodifiableList(requestPolicies_);
      } else {
        return requestPoliciesBuilder_.getMessageList();
      }
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public int getRequestPoliciesCount() {
      if (requestPoliciesBuilder_ == null) {
        return requestPolicies_.size();
      } else {
        return requestPoliciesBuilder_.getCount();
      }
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public com.google.api.FieldPolicy getRequestPolicies(int index) {
      if (requestPoliciesBuilder_ == null) {
        return requestPolicies_.get(index);
      } else {
        return requestPoliciesBuilder_.getMessage(index);
      }
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public Builder setRequestPolicies(int index, com.google.api.FieldPolicy value) {
      if (requestPoliciesBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureRequestPoliciesIsMutable();
        requestPolicies_.set(index, value);
        onChanged();
      } else {
        requestPoliciesBuilder_.setMessage(index, value);
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public Builder setRequestPolicies(
        int index, com.google.api.FieldPolicy.Builder builderForValue) {
      if (requestPoliciesBuilder_ == null) {
        ensureRequestPoliciesIsMutable();
        requestPolicies_.set(index, builderForValue.build());
        onChanged();
      } else {
        requestPoliciesBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public Builder addRequestPolicies(com.google.api.FieldPolicy value) {
      if (requestPoliciesBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureRequestPoliciesIsMutable();
        requestPolicies_.add(value);
        onChanged();
      } else {
        requestPoliciesBuilder_.addMessage(value);
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public Builder addRequestPolicies(int index, com.google.api.FieldPolicy value) {
      if (requestPoliciesBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureRequestPoliciesIsMutable();
        requestPolicies_.add(index, value);
        onChanged();
      } else {
        requestPoliciesBuilder_.addMessage(index, value);
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public Builder addRequestPolicies(com.google.api.FieldPolicy.Builder builderForValue) {
      if (requestPoliciesBuilder_ == null) {
        ensureRequestPoliciesIsMutable();
        requestPolicies_.add(builderForValue.build());
        onChanged();
      } else {
        requestPoliciesBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public Builder addRequestPolicies(
        int index, com.google.api.FieldPolicy.Builder builderForValue) {
      if (requestPoliciesBuilder_ == null) {
        ensureRequestPoliciesIsMutable();
        requestPolicies_.add(index, builderForValue.build());
        onChanged();
      } else {
        requestPoliciesBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public Builder addAllRequestPolicies(
        java.lang.Iterable<? extends com.google.api.FieldPolicy> values) {
      if (requestPoliciesBuilder_ == null) {
        ensureRequestPoliciesIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(values, requestPolicies_);
        onChanged();
      } else {
        requestPoliciesBuilder_.addAllMessages(values);
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public Builder clearRequestPolicies() {
      if (requestPoliciesBuilder_ == null) {
        requestPolicies_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000002);
        onChanged();
      } else {
        requestPoliciesBuilder_.clear();
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public Builder removeRequestPolicies(int index) {
      if (requestPoliciesBuilder_ == null) {
        ensureRequestPoliciesIsMutable();
        requestPolicies_.remove(index);
        onChanged();
      } else {
        requestPoliciesBuilder_.remove(index);
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public com.google.api.FieldPolicy.Builder getRequestPoliciesBuilder(int index) {
      return internalGetRequestPoliciesFieldBuilder().getBuilder(index);
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public com.google.api.FieldPolicyOrBuilder getRequestPoliciesOrBuilder(int index) {
      if (requestPoliciesBuilder_ == null) {
        return requestPolicies_.get(index);
      } else {
        return requestPoliciesBuilder_.getMessageOrBuilder(index);
      }
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public java.util.List<? extends com.google.api.FieldPolicyOrBuilder>
        getRequestPoliciesOrBuilderList() {
      if (requestPoliciesBuilder_ != null) {
        return requestPoliciesBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(requestPolicies_);
      }
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public com.google.api.FieldPolicy.Builder addRequestPoliciesBuilder() {
      return internalGetRequestPoliciesFieldBuilder()
          .addBuilder(com.google.api.FieldPolicy.getDefaultInstance());
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public com.google.api.FieldPolicy.Builder addRequestPoliciesBuilder(int index) {
      return internalGetRequestPoliciesFieldBuilder()
          .addBuilder(index, com.google.api.FieldPolicy.getDefaultInstance());
    }

    /**
     *
     *
     * <pre>
     * Policies that are applicable to the request message.
     * </pre>
     *
     * <code>repeated .google.api.FieldPolicy request_policies = 2;</code>
     */
    public java.util.List<com.google.api.FieldPolicy.Builder> getRequestPoliciesBuilderList() {
      return internalGetRequestPoliciesFieldBuilder().getBuilderList();
    }

    private com.google.protobuf.RepeatedFieldBuilder<
            com.google.api.FieldPolicy,
            com.google.api.FieldPolicy.Builder,
            com.google.api.FieldPolicyOrBuilder>
        internalGetRequestPoliciesFieldBuilder() {
      if (requestPoliciesBuilder_ == null) {
        requestPoliciesBuilder_ =
            new com.google.protobuf.RepeatedFieldBuilder<
                com.google.api.FieldPolicy,
                com.google.api.FieldPolicy.Builder,
                com.google.api.FieldPolicyOrBuilder>(
                requestPolicies_,
                ((bitField0_ & 0x00000002) != 0),
                getParentForChildren(),
                isClean());
        requestPolicies_ = null;
      }
      return requestPoliciesBuilder_;
    }

    // @@protoc_insertion_point(builder_scope:google.api.MethodPolicy)
  }

  // @@protoc_insertion_point(class_scope:google.api.MethodPolicy)
  private static final com.google.api.MethodPolicy DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.api.MethodPolicy();
  }

  public static com.google.api.MethodPolicy getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<MethodPolicy> PARSER =
      new com.google.protobuf.AbstractParser<MethodPolicy>() {
        @java.lang.Override
        public MethodPolicy 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<MethodPolicy> parser() {
    return PARSER;
  }

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

  @java.lang.Override
  public com.google.api.MethodPolicy getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}
