// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/spanner/v1/keys.proto

package com.google.spanner.v1;

/**
 * <pre>
 * `KeySet` defines a collection of Cloud Spanner keys and/or key ranges. All
 * the keys are expected to be in the same table or index. The keys need
 * not be sorted in any particular way.
 * If the same key is specified multiple times in the set (for example
 * if two ranges, two keys, or a key and a range overlap), Cloud Spanner
 * behaves as if the key were only specified once.
 * </pre>
 *
 * Protobuf type {@code google.spanner.v1.KeySet}
 */
public  final class KeySet extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:google.spanner.v1.KeySet)
    KeySetOrBuilder {
private static final long serialVersionUID = 0L;
  // Use KeySet.newBuilder() to construct.
  private KeySet(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private KeySet() {
    keys_ = java.util.Collections.emptyList();
    ranges_ = java.util.Collections.emptyList();
    all_ = false;
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return this.unknownFields;
  }
  private KeySet(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    if (extensionRegistry == null) {
      throw new java.lang.NullPointerException();
    }
    int mutable_bitField0_ = 0;
    com.google.protobuf.UnknownFieldSet.Builder unknownFields =
        com.google.protobuf.UnknownFieldSet.newBuilder();
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          default: {
            if (!parseUnknownFieldProto3(
                input, unknownFields, extensionRegistry, tag)) {
              done = true;
            }
            break;
          }
          case 10: {
            if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
              keys_ = new java.util.ArrayList<com.google.protobuf.ListValue>();
              mutable_bitField0_ |= 0x00000001;
            }
            keys_.add(
                input.readMessage(com.google.protobuf.ListValue.parser(), extensionRegistry));
            break;
          }
          case 18: {
            if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
              ranges_ = new java.util.ArrayList<com.google.spanner.v1.KeyRange>();
              mutable_bitField0_ |= 0x00000002;
            }
            ranges_.add(
                input.readMessage(com.google.spanner.v1.KeyRange.parser(), extensionRegistry));
            break;
          }
          case 24: {

            all_ = input.readBool();
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
        keys_ = java.util.Collections.unmodifiableList(keys_);
      }
      if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
        ranges_ = java.util.Collections.unmodifiableList(ranges_);
      }
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return com.google.spanner.v1.KeysProto.internal_static_google_spanner_v1_KeySet_descriptor;
  }

  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.spanner.v1.KeysProto.internal_static_google_spanner_v1_KeySet_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.spanner.v1.KeySet.class, com.google.spanner.v1.KeySet.Builder.class);
  }

  private int bitField0_;
  public static final int KEYS_FIELD_NUMBER = 1;
  private java.util.List<com.google.protobuf.ListValue> keys_;
  /**
   * <pre>
   * A list of specific keys. Entries in `keys` should have exactly as
   * many elements as there are columns in the primary or index key
   * with which this `KeySet` is used.  Individual key values are
   * encoded as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue keys = 1;</code>
   */
  public java.util.List<com.google.protobuf.ListValue> getKeysList() {
    return keys_;
  }
  /**
   * <pre>
   * A list of specific keys. Entries in `keys` should have exactly as
   * many elements as there are columns in the primary or index key
   * with which this `KeySet` is used.  Individual key values are
   * encoded as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue keys = 1;</code>
   */
  public java.util.List<? extends com.google.protobuf.ListValueOrBuilder> 
      getKeysOrBuilderList() {
    return keys_;
  }
  /**
   * <pre>
   * A list of specific keys. Entries in `keys` should have exactly as
   * many elements as there are columns in the primary or index key
   * with which this `KeySet` is used.  Individual key values are
   * encoded as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue keys = 1;</code>
   */
  public int getKeysCount() {
    return keys_.size();
  }
  /**
   * <pre>
   * A list of specific keys. Entries in `keys` should have exactly as
   * many elements as there are columns in the primary or index key
   * with which this `KeySet` is used.  Individual key values are
   * encoded as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue keys = 1;</code>
   */
  public com.google.protobuf.ListValue getKeys(int index) {
    return keys_.get(index);
  }
  /**
   * <pre>
   * A list of specific keys. Entries in `keys` should have exactly as
   * many elements as there are columns in the primary or index key
   * with which this `KeySet` is used.  Individual key values are
   * encoded as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue keys = 1;</code>
   */
  public com.google.protobuf.ListValueOrBuilder getKeysOrBuilder(
      int index) {
    return keys_.get(index);
  }

  public static final int RANGES_FIELD_NUMBER = 2;
  private java.util.List<com.google.spanner.v1.KeyRange> ranges_;
  /**
   * <pre>
   * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
   * key range specifications.
   * </pre>
   *
   * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
   */
  public java.util.List<com.google.spanner.v1.KeyRange> getRangesList() {
    return ranges_;
  }
  /**
   * <pre>
   * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
   * key range specifications.
   * </pre>
   *
   * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
   */
  public java.util.List<? extends com.google.spanner.v1.KeyRangeOrBuilder> 
      getRangesOrBuilderList() {
    return ranges_;
  }
  /**
   * <pre>
   * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
   * key range specifications.
   * </pre>
   *
   * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
   */
  public int getRangesCount() {
    return ranges_.size();
  }
  /**
   * <pre>
   * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
   * key range specifications.
   * </pre>
   *
   * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
   */
  public com.google.spanner.v1.KeyRange getRanges(int index) {
    return ranges_.get(index);
  }
  /**
   * <pre>
   * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
   * key range specifications.
   * </pre>
   *
   * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
   */
  public com.google.spanner.v1.KeyRangeOrBuilder getRangesOrBuilder(
      int index) {
    return ranges_.get(index);
  }

  public static final int ALL_FIELD_NUMBER = 3;
  private boolean all_;
  /**
   * <pre>
   * For convenience `all` can be set to `true` to indicate that this
   * `KeySet` matches all keys in the table or index. Note that any keys
   * specified in `keys` or `ranges` are only yielded once.
   * </pre>
   *
   * <code>bool all = 3;</code>
   */
  public boolean getAll() {
    return all_;
  }

  private byte memoizedIsInitialized = -1;
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  public void writeTo(com.google.protobuf.CodedOutputStream output)
                      throws java.io.IOException {
    for (int i = 0; i < keys_.size(); i++) {
      output.writeMessage(1, keys_.get(i));
    }
    for (int i = 0; i < ranges_.size(); i++) {
      output.writeMessage(2, ranges_.get(i));
    }
    if (all_ != false) {
      output.writeBool(3, all_);
    }
    unknownFields.writeTo(output);
  }

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

    size = 0;
    for (int i = 0; i < keys_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(1, keys_.get(i));
    }
    for (int i = 0; i < ranges_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(2, ranges_.get(i));
    }
    if (all_ != false) {
      size += com.google.protobuf.CodedOutputStream
        .computeBoolSize(3, all_);
    }
    size += unknownFields.getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
     return true;
    }
    if (!(obj instanceof com.google.spanner.v1.KeySet)) {
      return super.equals(obj);
    }
    com.google.spanner.v1.KeySet other = (com.google.spanner.v1.KeySet) obj;

    boolean result = true;
    result = result && getKeysList()
        .equals(other.getKeysList());
    result = result && getRangesList()
        .equals(other.getRangesList());
    result = result && (getAll()
        == other.getAll());
    result = result && unknownFields.equals(other.unknownFields);
    return result;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    if (getKeysCount() > 0) {
      hash = (37 * hash) + KEYS_FIELD_NUMBER;
      hash = (53 * hash) + getKeysList().hashCode();
    }
    if (getRangesCount() > 0) {
      hash = (37 * hash) + RANGES_FIELD_NUMBER;
      hash = (53 * hash) + getRangesList().hashCode();
    }
    hash = (37 * hash) + ALL_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
        getAll());
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.spanner.v1.KeySet parseFrom(
      java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.spanner.v1.KeySet parseFrom(
      java.nio.ByteBuffer data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.spanner.v1.KeySet parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.spanner.v1.KeySet 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.spanner.v1.KeySet parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.spanner.v1.KeySet parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.spanner.v1.KeySet parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.spanner.v1.KeySet 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.spanner.v1.KeySet parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static com.google.spanner.v1.KeySet 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.spanner.v1.KeySet parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.spanner.v1.KeySet parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }

  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }
  public static Builder newBuilder(com.google.spanner.v1.KeySet prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }
  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>
   * `KeySet` defines a collection of Cloud Spanner keys and/or key ranges. All
   * the keys are expected to be in the same table or index. The keys need
   * not be sorted in any particular way.
   * If the same key is specified multiple times in the set (for example
   * if two ranges, two keys, or a key and a range overlap), Cloud Spanner
   * behaves as if the key were only specified once.
   * </pre>
   *
   * Protobuf type {@code google.spanner.v1.KeySet}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:google.spanner.v1.KeySet)
      com.google.spanner.v1.KeySetOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return com.google.spanner.v1.KeysProto.internal_static_google_spanner_v1_KeySet_descriptor;
    }

    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.spanner.v1.KeysProto.internal_static_google_spanner_v1_KeySet_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.spanner.v1.KeySet.class, com.google.spanner.v1.KeySet.Builder.class);
    }

    // Construct using com.google.spanner.v1.KeySet.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
        getKeysFieldBuilder();
        getRangesFieldBuilder();
      }
    }
    public Builder clear() {
      super.clear();
      if (keysBuilder_ == null) {
        keys_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
      } else {
        keysBuilder_.clear();
      }
      if (rangesBuilder_ == null) {
        ranges_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000002);
      } else {
        rangesBuilder_.clear();
      }
      all_ = false;

      return this;
    }

    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return com.google.spanner.v1.KeysProto.internal_static_google_spanner_v1_KeySet_descriptor;
    }

    public com.google.spanner.v1.KeySet getDefaultInstanceForType() {
      return com.google.spanner.v1.KeySet.getDefaultInstance();
    }

    public com.google.spanner.v1.KeySet build() {
      com.google.spanner.v1.KeySet result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    public com.google.spanner.v1.KeySet buildPartial() {
      com.google.spanner.v1.KeySet result = new com.google.spanner.v1.KeySet(this);
      int from_bitField0_ = bitField0_;
      int to_bitField0_ = 0;
      if (keysBuilder_ == null) {
        if (((bitField0_ & 0x00000001) == 0x00000001)) {
          keys_ = java.util.Collections.unmodifiableList(keys_);
          bitField0_ = (bitField0_ & ~0x00000001);
        }
        result.keys_ = keys_;
      } else {
        result.keys_ = keysBuilder_.build();
      }
      if (rangesBuilder_ == null) {
        if (((bitField0_ & 0x00000002) == 0x00000002)) {
          ranges_ = java.util.Collections.unmodifiableList(ranges_);
          bitField0_ = (bitField0_ & ~0x00000002);
        }
        result.ranges_ = ranges_;
      } else {
        result.ranges_ = rangesBuilder_.build();
      }
      result.all_ = all_;
      result.bitField0_ = to_bitField0_;
      onBuilt();
      return result;
    }

    public Builder clone() {
      return (Builder) super.clone();
    }
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return (Builder) super.setField(field, value);
    }
    public Builder clearField(
        com.google.protobuf.Descriptors.FieldDescriptor field) {
      return (Builder) super.clearField(field);
    }
    public Builder clearOneof(
        com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return (Builder) super.clearOneof(oneof);
    }
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        int index, java.lang.Object value) {
      return (Builder) super.setRepeatedField(field, index, value);
    }
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return (Builder) super.addRepeatedField(field, value);
    }
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.spanner.v1.KeySet) {
        return mergeFrom((com.google.spanner.v1.KeySet)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.spanner.v1.KeySet other) {
      if (other == com.google.spanner.v1.KeySet.getDefaultInstance()) return this;
      if (keysBuilder_ == null) {
        if (!other.keys_.isEmpty()) {
          if (keys_.isEmpty()) {
            keys_ = other.keys_;
            bitField0_ = (bitField0_ & ~0x00000001);
          } else {
            ensureKeysIsMutable();
            keys_.addAll(other.keys_);
          }
          onChanged();
        }
      } else {
        if (!other.keys_.isEmpty()) {
          if (keysBuilder_.isEmpty()) {
            keysBuilder_.dispose();
            keysBuilder_ = null;
            keys_ = other.keys_;
            bitField0_ = (bitField0_ & ~0x00000001);
            keysBuilder_ = 
              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
                 getKeysFieldBuilder() : null;
          } else {
            keysBuilder_.addAllMessages(other.keys_);
          }
        }
      }
      if (rangesBuilder_ == null) {
        if (!other.ranges_.isEmpty()) {
          if (ranges_.isEmpty()) {
            ranges_ = other.ranges_;
            bitField0_ = (bitField0_ & ~0x00000002);
          } else {
            ensureRangesIsMutable();
            ranges_.addAll(other.ranges_);
          }
          onChanged();
        }
      } else {
        if (!other.ranges_.isEmpty()) {
          if (rangesBuilder_.isEmpty()) {
            rangesBuilder_.dispose();
            rangesBuilder_ = null;
            ranges_ = other.ranges_;
            bitField0_ = (bitField0_ & ~0x00000002);
            rangesBuilder_ = 
              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
                 getRangesFieldBuilder() : null;
          } else {
            rangesBuilder_.addAllMessages(other.ranges_);
          }
        }
      }
      if (other.getAll() != false) {
        setAll(other.getAll());
      }
      this.mergeUnknownFields(other.unknownFields);
      onChanged();
      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.google.spanner.v1.KeySet parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (com.google.spanner.v1.KeySet) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }
    private int bitField0_;

    private java.util.List<com.google.protobuf.ListValue> keys_ =
      java.util.Collections.emptyList();
    private void ensureKeysIsMutable() {
      if (!((bitField0_ & 0x00000001) == 0x00000001)) {
        keys_ = new java.util.ArrayList<com.google.protobuf.ListValue>(keys_);
        bitField0_ |= 0x00000001;
       }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder> keysBuilder_;

    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public java.util.List<com.google.protobuf.ListValue> getKeysList() {
      if (keysBuilder_ == null) {
        return java.util.Collections.unmodifiableList(keys_);
      } else {
        return keysBuilder_.getMessageList();
      }
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public int getKeysCount() {
      if (keysBuilder_ == null) {
        return keys_.size();
      } else {
        return keysBuilder_.getCount();
      }
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public com.google.protobuf.ListValue getKeys(int index) {
      if (keysBuilder_ == null) {
        return keys_.get(index);
      } else {
        return keysBuilder_.getMessage(index);
      }
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public Builder setKeys(
        int index, com.google.protobuf.ListValue value) {
      if (keysBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureKeysIsMutable();
        keys_.set(index, value);
        onChanged();
      } else {
        keysBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public Builder setKeys(
        int index, com.google.protobuf.ListValue.Builder builderForValue) {
      if (keysBuilder_ == null) {
        ensureKeysIsMutable();
        keys_.set(index, builderForValue.build());
        onChanged();
      } else {
        keysBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public Builder addKeys(com.google.protobuf.ListValue value) {
      if (keysBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureKeysIsMutable();
        keys_.add(value);
        onChanged();
      } else {
        keysBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public Builder addKeys(
        int index, com.google.protobuf.ListValue value) {
      if (keysBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureKeysIsMutable();
        keys_.add(index, value);
        onChanged();
      } else {
        keysBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public Builder addKeys(
        com.google.protobuf.ListValue.Builder builderForValue) {
      if (keysBuilder_ == null) {
        ensureKeysIsMutable();
        keys_.add(builderForValue.build());
        onChanged();
      } else {
        keysBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public Builder addKeys(
        int index, com.google.protobuf.ListValue.Builder builderForValue) {
      if (keysBuilder_ == null) {
        ensureKeysIsMutable();
        keys_.add(index, builderForValue.build());
        onChanged();
      } else {
        keysBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public Builder addAllKeys(
        java.lang.Iterable<? extends com.google.protobuf.ListValue> values) {
      if (keysBuilder_ == null) {
        ensureKeysIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(
            values, keys_);
        onChanged();
      } else {
        keysBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public Builder clearKeys() {
      if (keysBuilder_ == null) {
        keys_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
        onChanged();
      } else {
        keysBuilder_.clear();
      }
      return this;
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public Builder removeKeys(int index) {
      if (keysBuilder_ == null) {
        ensureKeysIsMutable();
        keys_.remove(index);
        onChanged();
      } else {
        keysBuilder_.remove(index);
      }
      return this;
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public com.google.protobuf.ListValue.Builder getKeysBuilder(
        int index) {
      return getKeysFieldBuilder().getBuilder(index);
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public com.google.protobuf.ListValueOrBuilder getKeysOrBuilder(
        int index) {
      if (keysBuilder_ == null) {
        return keys_.get(index);  } else {
        return keysBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public java.util.List<? extends com.google.protobuf.ListValueOrBuilder> 
         getKeysOrBuilderList() {
      if (keysBuilder_ != null) {
        return keysBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(keys_);
      }
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public com.google.protobuf.ListValue.Builder addKeysBuilder() {
      return getKeysFieldBuilder().addBuilder(
          com.google.protobuf.ListValue.getDefaultInstance());
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public com.google.protobuf.ListValue.Builder addKeysBuilder(
        int index) {
      return getKeysFieldBuilder().addBuilder(
          index, com.google.protobuf.ListValue.getDefaultInstance());
    }
    /**
     * <pre>
     * A list of specific keys. Entries in `keys` should have exactly as
     * many elements as there are columns in the primary or index key
     * with which this `KeySet` is used.  Individual key values are
     * encoded as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue keys = 1;</code>
     */
    public java.util.List<com.google.protobuf.ListValue.Builder> 
         getKeysBuilderList() {
      return getKeysFieldBuilder().getBuilderList();
    }
    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder> 
        getKeysFieldBuilder() {
      if (keysBuilder_ == null) {
        keysBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder>(
                keys_,
                ((bitField0_ & 0x00000001) == 0x00000001),
                getParentForChildren(),
                isClean());
        keys_ = null;
      }
      return keysBuilder_;
    }

    private java.util.List<com.google.spanner.v1.KeyRange> ranges_ =
      java.util.Collections.emptyList();
    private void ensureRangesIsMutable() {
      if (!((bitField0_ & 0x00000002) == 0x00000002)) {
        ranges_ = new java.util.ArrayList<com.google.spanner.v1.KeyRange>(ranges_);
        bitField0_ |= 0x00000002;
       }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.spanner.v1.KeyRange, com.google.spanner.v1.KeyRange.Builder, com.google.spanner.v1.KeyRangeOrBuilder> rangesBuilder_;

    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public java.util.List<com.google.spanner.v1.KeyRange> getRangesList() {
      if (rangesBuilder_ == null) {
        return java.util.Collections.unmodifiableList(ranges_);
      } else {
        return rangesBuilder_.getMessageList();
      }
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public int getRangesCount() {
      if (rangesBuilder_ == null) {
        return ranges_.size();
      } else {
        return rangesBuilder_.getCount();
      }
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public com.google.spanner.v1.KeyRange getRanges(int index) {
      if (rangesBuilder_ == null) {
        return ranges_.get(index);
      } else {
        return rangesBuilder_.getMessage(index);
      }
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public Builder setRanges(
        int index, com.google.spanner.v1.KeyRange value) {
      if (rangesBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureRangesIsMutable();
        ranges_.set(index, value);
        onChanged();
      } else {
        rangesBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public Builder setRanges(
        int index, com.google.spanner.v1.KeyRange.Builder builderForValue) {
      if (rangesBuilder_ == null) {
        ensureRangesIsMutable();
        ranges_.set(index, builderForValue.build());
        onChanged();
      } else {
        rangesBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public Builder addRanges(com.google.spanner.v1.KeyRange value) {
      if (rangesBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureRangesIsMutable();
        ranges_.add(value);
        onChanged();
      } else {
        rangesBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public Builder addRanges(
        int index, com.google.spanner.v1.KeyRange value) {
      if (rangesBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureRangesIsMutable();
        ranges_.add(index, value);
        onChanged();
      } else {
        rangesBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public Builder addRanges(
        com.google.spanner.v1.KeyRange.Builder builderForValue) {
      if (rangesBuilder_ == null) {
        ensureRangesIsMutable();
        ranges_.add(builderForValue.build());
        onChanged();
      } else {
        rangesBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public Builder addRanges(
        int index, com.google.spanner.v1.KeyRange.Builder builderForValue) {
      if (rangesBuilder_ == null) {
        ensureRangesIsMutable();
        ranges_.add(index, builderForValue.build());
        onChanged();
      } else {
        rangesBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public Builder addAllRanges(
        java.lang.Iterable<? extends com.google.spanner.v1.KeyRange> values) {
      if (rangesBuilder_ == null) {
        ensureRangesIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(
            values, ranges_);
        onChanged();
      } else {
        rangesBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public Builder clearRanges() {
      if (rangesBuilder_ == null) {
        ranges_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000002);
        onChanged();
      } else {
        rangesBuilder_.clear();
      }
      return this;
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public Builder removeRanges(int index) {
      if (rangesBuilder_ == null) {
        ensureRangesIsMutable();
        ranges_.remove(index);
        onChanged();
      } else {
        rangesBuilder_.remove(index);
      }
      return this;
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public com.google.spanner.v1.KeyRange.Builder getRangesBuilder(
        int index) {
      return getRangesFieldBuilder().getBuilder(index);
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public com.google.spanner.v1.KeyRangeOrBuilder getRangesOrBuilder(
        int index) {
      if (rangesBuilder_ == null) {
        return ranges_.get(index);  } else {
        return rangesBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public java.util.List<? extends com.google.spanner.v1.KeyRangeOrBuilder> 
         getRangesOrBuilderList() {
      if (rangesBuilder_ != null) {
        return rangesBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(ranges_);
      }
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public com.google.spanner.v1.KeyRange.Builder addRangesBuilder() {
      return getRangesFieldBuilder().addBuilder(
          com.google.spanner.v1.KeyRange.getDefaultInstance());
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public com.google.spanner.v1.KeyRange.Builder addRangesBuilder(
        int index) {
      return getRangesFieldBuilder().addBuilder(
          index, com.google.spanner.v1.KeyRange.getDefaultInstance());
    }
    /**
     * <pre>
     * A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more information about
     * key range specifications.
     * </pre>
     *
     * <code>repeated .google.spanner.v1.KeyRange ranges = 2;</code>
     */
    public java.util.List<com.google.spanner.v1.KeyRange.Builder> 
         getRangesBuilderList() {
      return getRangesFieldBuilder().getBuilderList();
    }
    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.spanner.v1.KeyRange, com.google.spanner.v1.KeyRange.Builder, com.google.spanner.v1.KeyRangeOrBuilder> 
        getRangesFieldBuilder() {
      if (rangesBuilder_ == null) {
        rangesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.spanner.v1.KeyRange, com.google.spanner.v1.KeyRange.Builder, com.google.spanner.v1.KeyRangeOrBuilder>(
                ranges_,
                ((bitField0_ & 0x00000002) == 0x00000002),
                getParentForChildren(),
                isClean());
        ranges_ = null;
      }
      return rangesBuilder_;
    }

    private boolean all_ ;
    /**
     * <pre>
     * For convenience `all` can be set to `true` to indicate that this
     * `KeySet` matches all keys in the table or index. Note that any keys
     * specified in `keys` or `ranges` are only yielded once.
     * </pre>
     *
     * <code>bool all = 3;</code>
     */
    public boolean getAll() {
      return all_;
    }
    /**
     * <pre>
     * For convenience `all` can be set to `true` to indicate that this
     * `KeySet` matches all keys in the table or index. Note that any keys
     * specified in `keys` or `ranges` are only yielded once.
     * </pre>
     *
     * <code>bool all = 3;</code>
     */
    public Builder setAll(boolean value) {
      
      all_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * For convenience `all` can be set to `true` to indicate that this
     * `KeySet` matches all keys in the table or index. Note that any keys
     * specified in `keys` or `ranges` are only yielded once.
     * </pre>
     *
     * <code>bool all = 3;</code>
     */
    public Builder clearAll() {
      
      all_ = false;
      onChanged();
      return this;
    }
    public final Builder setUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFieldsProto3(unknownFields);
    }

    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }


    // @@protoc_insertion_point(builder_scope:google.spanner.v1.KeySet)
  }

  // @@protoc_insertion_point(class_scope:google.spanner.v1.KeySet)
  private static final com.google.spanner.v1.KeySet DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new com.google.spanner.v1.KeySet();
  }

  public static com.google.spanner.v1.KeySet getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

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

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

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

  public com.google.spanner.v1.KeySet getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}

