// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/firestore/v1beta1/document.proto

package com.google.firestore.v1beta1;

/**
 * <pre>
 * A message that can hold any of the supported value types.
 * </pre>
 *
 * Protobuf type {@code google.firestore.v1beta1.Value}
 */
public  final class Value extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:google.firestore.v1beta1.Value)
    ValueOrBuilder {
private static final long serialVersionUID = 0L;
  // Use Value.newBuilder() to construct.
  private Value(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private Value() {
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return this.unknownFields;
  }
  private Value(
      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 8: {
            valueTypeCase_ = 1;
            valueType_ = input.readBool();
            break;
          }
          case 16: {
            valueTypeCase_ = 2;
            valueType_ = input.readInt64();
            break;
          }
          case 25: {
            valueTypeCase_ = 3;
            valueType_ = input.readDouble();
            break;
          }
          case 42: {
            java.lang.String s = input.readStringRequireUtf8();
            valueTypeCase_ = 5;
            valueType_ = s;
            break;
          }
          case 50: {
            com.google.firestore.v1beta1.MapValue.Builder subBuilder = null;
            if (valueTypeCase_ == 6) {
              subBuilder = ((com.google.firestore.v1beta1.MapValue) valueType_).toBuilder();
            }
            valueType_ =
                input.readMessage(com.google.firestore.v1beta1.MapValue.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom((com.google.firestore.v1beta1.MapValue) valueType_);
              valueType_ = subBuilder.buildPartial();
            }
            valueTypeCase_ = 6;
            break;
          }
          case 66: {
            com.google.type.LatLng.Builder subBuilder = null;
            if (valueTypeCase_ == 8) {
              subBuilder = ((com.google.type.LatLng) valueType_).toBuilder();
            }
            valueType_ =
                input.readMessage(com.google.type.LatLng.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom((com.google.type.LatLng) valueType_);
              valueType_ = subBuilder.buildPartial();
            }
            valueTypeCase_ = 8;
            break;
          }
          case 74: {
            com.google.firestore.v1beta1.ArrayValue.Builder subBuilder = null;
            if (valueTypeCase_ == 9) {
              subBuilder = ((com.google.firestore.v1beta1.ArrayValue) valueType_).toBuilder();
            }
            valueType_ =
                input.readMessage(com.google.firestore.v1beta1.ArrayValue.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom((com.google.firestore.v1beta1.ArrayValue) valueType_);
              valueType_ = subBuilder.buildPartial();
            }
            valueTypeCase_ = 9;
            break;
          }
          case 82: {
            com.google.protobuf.Timestamp.Builder subBuilder = null;
            if (valueTypeCase_ == 10) {
              subBuilder = ((com.google.protobuf.Timestamp) valueType_).toBuilder();
            }
            valueType_ =
                input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom((com.google.protobuf.Timestamp) valueType_);
              valueType_ = subBuilder.buildPartial();
            }
            valueTypeCase_ = 10;
            break;
          }
          case 88: {
            int rawValue = input.readEnum();
            valueTypeCase_ = 11;
            valueType_ = rawValue;
            break;
          }
          case 138: {
            java.lang.String s = input.readStringRequireUtf8();
            valueTypeCase_ = 17;
            valueType_ = s;
            break;
          }
          case 146: {
            valueTypeCase_ = 18;
            valueType_ = input.readBytes();
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return com.google.firestore.v1beta1.DocumentProto.internal_static_google_firestore_v1beta1_Value_descriptor;
  }

  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.firestore.v1beta1.DocumentProto.internal_static_google_firestore_v1beta1_Value_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.firestore.v1beta1.Value.class, com.google.firestore.v1beta1.Value.Builder.class);
  }

  private int valueTypeCase_ = 0;
  private java.lang.Object valueType_;
  public enum ValueTypeCase
      implements com.google.protobuf.Internal.EnumLite {
    NULL_VALUE(11),
    BOOLEAN_VALUE(1),
    INTEGER_VALUE(2),
    DOUBLE_VALUE(3),
    TIMESTAMP_VALUE(10),
    STRING_VALUE(17),
    BYTES_VALUE(18),
    REFERENCE_VALUE(5),
    GEO_POINT_VALUE(8),
    ARRAY_VALUE(9),
    MAP_VALUE(6),
    VALUETYPE_NOT_SET(0);
    private final int value;
    private ValueTypeCase(int value) {
      this.value = value;
    }
    /**
     * @deprecated Use {@link #forNumber(int)} instead.
     */
    @java.lang.Deprecated
    public static ValueTypeCase valueOf(int value) {
      return forNumber(value);
    }

    public static ValueTypeCase forNumber(int value) {
      switch (value) {
        case 11: return NULL_VALUE;
        case 1: return BOOLEAN_VALUE;
        case 2: return INTEGER_VALUE;
        case 3: return DOUBLE_VALUE;
        case 10: return TIMESTAMP_VALUE;
        case 17: return STRING_VALUE;
        case 18: return BYTES_VALUE;
        case 5: return REFERENCE_VALUE;
        case 8: return GEO_POINT_VALUE;
        case 9: return ARRAY_VALUE;
        case 6: return MAP_VALUE;
        case 0: return VALUETYPE_NOT_SET;
        default: return null;
      }
    }
    public int getNumber() {
      return this.value;
    }
  };

  public ValueTypeCase
  getValueTypeCase() {
    return ValueTypeCase.forNumber(
        valueTypeCase_);
  }

  public static final int NULL_VALUE_FIELD_NUMBER = 11;
  /**
   * <pre>
   * A null value.
   * </pre>
   *
   * <code>.google.protobuf.NullValue null_value = 11;</code>
   */
  public int getNullValueValue() {
    if (valueTypeCase_ == 11) {
      return (java.lang.Integer) valueType_;
    }
    return 0;
  }
  /**
   * <pre>
   * A null value.
   * </pre>
   *
   * <code>.google.protobuf.NullValue null_value = 11;</code>
   */
  public com.google.protobuf.NullValue getNullValue() {
    if (valueTypeCase_ == 11) {
      com.google.protobuf.NullValue result = com.google.protobuf.NullValue.valueOf(
          (java.lang.Integer) valueType_);
      return result == null ? com.google.protobuf.NullValue.UNRECOGNIZED : result;
    }
    return com.google.protobuf.NullValue.NULL_VALUE;
  }

  public static final int BOOLEAN_VALUE_FIELD_NUMBER = 1;
  /**
   * <pre>
   * A boolean value.
   * </pre>
   *
   * <code>bool boolean_value = 1;</code>
   */
  public boolean getBooleanValue() {
    if (valueTypeCase_ == 1) {
      return (java.lang.Boolean) valueType_;
    }
    return false;
  }

  public static final int INTEGER_VALUE_FIELD_NUMBER = 2;
  /**
   * <pre>
   * An integer value.
   * </pre>
   *
   * <code>int64 integer_value = 2;</code>
   */
  public long getIntegerValue() {
    if (valueTypeCase_ == 2) {
      return (java.lang.Long) valueType_;
    }
    return 0L;
  }

  public static final int DOUBLE_VALUE_FIELD_NUMBER = 3;
  /**
   * <pre>
   * A double value.
   * </pre>
   *
   * <code>double double_value = 3;</code>
   */
  public double getDoubleValue() {
    if (valueTypeCase_ == 3) {
      return (java.lang.Double) valueType_;
    }
    return 0D;
  }

  public static final int TIMESTAMP_VALUE_FIELD_NUMBER = 10;
  /**
   * <pre>
   * A timestamp value.
   * Precise only to microseconds. When stored, any additional precision is
   * rounded down.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
   */
  public boolean hasTimestampValue() {
    return valueTypeCase_ == 10;
  }
  /**
   * <pre>
   * A timestamp value.
   * Precise only to microseconds. When stored, any additional precision is
   * rounded down.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
   */
  public com.google.protobuf.Timestamp getTimestampValue() {
    if (valueTypeCase_ == 10) {
       return (com.google.protobuf.Timestamp) valueType_;
    }
    return com.google.protobuf.Timestamp.getDefaultInstance();
  }
  /**
   * <pre>
   * A timestamp value.
   * Precise only to microseconds. When stored, any additional precision is
   * rounded down.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
   */
  public com.google.protobuf.TimestampOrBuilder getTimestampValueOrBuilder() {
    if (valueTypeCase_ == 10) {
       return (com.google.protobuf.Timestamp) valueType_;
    }
    return com.google.protobuf.Timestamp.getDefaultInstance();
  }

  public static final int STRING_VALUE_FIELD_NUMBER = 17;
  /**
   * <pre>
   * A string value.
   * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
   * Only the first 1,500 bytes of the UTF-8 representation are considered by
   * queries.
   * </pre>
   *
   * <code>string string_value = 17;</code>
   */
  public java.lang.String getStringValue() {
    java.lang.Object ref = "";
    if (valueTypeCase_ == 17) {
      ref = valueType_;
    }
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      if (valueTypeCase_ == 17) {
        valueType_ = s;
      }
      return s;
    }
  }
  /**
   * <pre>
   * A string value.
   * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
   * Only the first 1,500 bytes of the UTF-8 representation are considered by
   * queries.
   * </pre>
   *
   * <code>string string_value = 17;</code>
   */
  public com.google.protobuf.ByteString
      getStringValueBytes() {
    java.lang.Object ref = "";
    if (valueTypeCase_ == 17) {
      ref = valueType_;
    }
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      if (valueTypeCase_ == 17) {
        valueType_ = b;
      }
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int BYTES_VALUE_FIELD_NUMBER = 18;
  /**
   * <pre>
   * A bytes value.
   * Must not exceed 1 MiB - 89 bytes.
   * Only the first 1,500 bytes are considered by queries.
   * </pre>
   *
   * <code>bytes bytes_value = 18;</code>
   */
  public com.google.protobuf.ByteString getBytesValue() {
    if (valueTypeCase_ == 18) {
      return (com.google.protobuf.ByteString) valueType_;
    }
    return com.google.protobuf.ByteString.EMPTY;
  }

  public static final int REFERENCE_VALUE_FIELD_NUMBER = 5;
  /**
   * <pre>
   * A reference to a document. For example:
   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
   * </pre>
   *
   * <code>string reference_value = 5;</code>
   */
  public java.lang.String getReferenceValue() {
    java.lang.Object ref = "";
    if (valueTypeCase_ == 5) {
      ref = valueType_;
    }
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      if (valueTypeCase_ == 5) {
        valueType_ = s;
      }
      return s;
    }
  }
  /**
   * <pre>
   * A reference to a document. For example:
   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
   * </pre>
   *
   * <code>string reference_value = 5;</code>
   */
  public com.google.protobuf.ByteString
      getReferenceValueBytes() {
    java.lang.Object ref = "";
    if (valueTypeCase_ == 5) {
      ref = valueType_;
    }
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      if (valueTypeCase_ == 5) {
        valueType_ = b;
      }
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int GEO_POINT_VALUE_FIELD_NUMBER = 8;
  /**
   * <pre>
   * A geo point value representing a point on the surface of Earth.
   * </pre>
   *
   * <code>.google.type.LatLng geo_point_value = 8;</code>
   */
  public boolean hasGeoPointValue() {
    return valueTypeCase_ == 8;
  }
  /**
   * <pre>
   * A geo point value representing a point on the surface of Earth.
   * </pre>
   *
   * <code>.google.type.LatLng geo_point_value = 8;</code>
   */
  public com.google.type.LatLng getGeoPointValue() {
    if (valueTypeCase_ == 8) {
       return (com.google.type.LatLng) valueType_;
    }
    return com.google.type.LatLng.getDefaultInstance();
  }
  /**
   * <pre>
   * A geo point value representing a point on the surface of Earth.
   * </pre>
   *
   * <code>.google.type.LatLng geo_point_value = 8;</code>
   */
  public com.google.type.LatLngOrBuilder getGeoPointValueOrBuilder() {
    if (valueTypeCase_ == 8) {
       return (com.google.type.LatLng) valueType_;
    }
    return com.google.type.LatLng.getDefaultInstance();
  }

  public static final int ARRAY_VALUE_FIELD_NUMBER = 9;
  /**
   * <pre>
   * An array value.
   * Cannot contain another array value.
   * </pre>
   *
   * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
   */
  public boolean hasArrayValue() {
    return valueTypeCase_ == 9;
  }
  /**
   * <pre>
   * An array value.
   * Cannot contain another array value.
   * </pre>
   *
   * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
   */
  public com.google.firestore.v1beta1.ArrayValue getArrayValue() {
    if (valueTypeCase_ == 9) {
       return (com.google.firestore.v1beta1.ArrayValue) valueType_;
    }
    return com.google.firestore.v1beta1.ArrayValue.getDefaultInstance();
  }
  /**
   * <pre>
   * An array value.
   * Cannot contain another array value.
   * </pre>
   *
   * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
   */
  public com.google.firestore.v1beta1.ArrayValueOrBuilder getArrayValueOrBuilder() {
    if (valueTypeCase_ == 9) {
       return (com.google.firestore.v1beta1.ArrayValue) valueType_;
    }
    return com.google.firestore.v1beta1.ArrayValue.getDefaultInstance();
  }

  public static final int MAP_VALUE_FIELD_NUMBER = 6;
  /**
   * <pre>
   * A map value.
   * </pre>
   *
   * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
   */
  public boolean hasMapValue() {
    return valueTypeCase_ == 6;
  }
  /**
   * <pre>
   * A map value.
   * </pre>
   *
   * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
   */
  public com.google.firestore.v1beta1.MapValue getMapValue() {
    if (valueTypeCase_ == 6) {
       return (com.google.firestore.v1beta1.MapValue) valueType_;
    }
    return com.google.firestore.v1beta1.MapValue.getDefaultInstance();
  }
  /**
   * <pre>
   * A map value.
   * </pre>
   *
   * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
   */
  public com.google.firestore.v1beta1.MapValueOrBuilder getMapValueOrBuilder() {
    if (valueTypeCase_ == 6) {
       return (com.google.firestore.v1beta1.MapValue) valueType_;
    }
    return com.google.firestore.v1beta1.MapValue.getDefaultInstance();
  }

  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 {
    if (valueTypeCase_ == 1) {
      output.writeBool(
          1, (boolean)((java.lang.Boolean) valueType_));
    }
    if (valueTypeCase_ == 2) {
      output.writeInt64(
          2, (long)((java.lang.Long) valueType_));
    }
    if (valueTypeCase_ == 3) {
      output.writeDouble(
          3, (double)((java.lang.Double) valueType_));
    }
    if (valueTypeCase_ == 5) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 5, valueType_);
    }
    if (valueTypeCase_ == 6) {
      output.writeMessage(6, (com.google.firestore.v1beta1.MapValue) valueType_);
    }
    if (valueTypeCase_ == 8) {
      output.writeMessage(8, (com.google.type.LatLng) valueType_);
    }
    if (valueTypeCase_ == 9) {
      output.writeMessage(9, (com.google.firestore.v1beta1.ArrayValue) valueType_);
    }
    if (valueTypeCase_ == 10) {
      output.writeMessage(10, (com.google.protobuf.Timestamp) valueType_);
    }
    if (valueTypeCase_ == 11) {
      output.writeEnum(11, ((java.lang.Integer) valueType_));
    }
    if (valueTypeCase_ == 17) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 17, valueType_);
    }
    if (valueTypeCase_ == 18) {
      output.writeBytes(
          18, (com.google.protobuf.ByteString) valueType_);
    }
    unknownFields.writeTo(output);
  }

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

    size = 0;
    if (valueTypeCase_ == 1) {
      size += com.google.protobuf.CodedOutputStream
        .computeBoolSize(
            1, (boolean)((java.lang.Boolean) valueType_));
    }
    if (valueTypeCase_ == 2) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt64Size(
            2, (long)((java.lang.Long) valueType_));
    }
    if (valueTypeCase_ == 3) {
      size += com.google.protobuf.CodedOutputStream
        .computeDoubleSize(
            3, (double)((java.lang.Double) valueType_));
    }
    if (valueTypeCase_ == 5) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, valueType_);
    }
    if (valueTypeCase_ == 6) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(6, (com.google.firestore.v1beta1.MapValue) valueType_);
    }
    if (valueTypeCase_ == 8) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(8, (com.google.type.LatLng) valueType_);
    }
    if (valueTypeCase_ == 9) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(9, (com.google.firestore.v1beta1.ArrayValue) valueType_);
    }
    if (valueTypeCase_ == 10) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(10, (com.google.protobuf.Timestamp) valueType_);
    }
    if (valueTypeCase_ == 11) {
      size += com.google.protobuf.CodedOutputStream
        .computeEnumSize(11, ((java.lang.Integer) valueType_));
    }
    if (valueTypeCase_ == 17) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(17, valueType_);
    }
    if (valueTypeCase_ == 18) {
      size += com.google.protobuf.CodedOutputStream
        .computeBytesSize(
            18, (com.google.protobuf.ByteString) valueType_);
    }
    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.firestore.v1beta1.Value)) {
      return super.equals(obj);
    }
    com.google.firestore.v1beta1.Value other = (com.google.firestore.v1beta1.Value) obj;

    boolean result = true;
    result = result && getValueTypeCase().equals(
        other.getValueTypeCase());
    if (!result) return false;
    switch (valueTypeCase_) {
      case 11:
        result = result && getNullValueValue()
            == other.getNullValueValue();
        break;
      case 1:
        result = result && (getBooleanValue()
            == other.getBooleanValue());
        break;
      case 2:
        result = result && (getIntegerValue()
            == other.getIntegerValue());
        break;
      case 3:
        result = result && (
            java.lang.Double.doubleToLongBits(getDoubleValue())
            == java.lang.Double.doubleToLongBits(
                other.getDoubleValue()));
        break;
      case 10:
        result = result && getTimestampValue()
            .equals(other.getTimestampValue());
        break;
      case 17:
        result = result && getStringValue()
            .equals(other.getStringValue());
        break;
      case 18:
        result = result && getBytesValue()
            .equals(other.getBytesValue());
        break;
      case 5:
        result = result && getReferenceValue()
            .equals(other.getReferenceValue());
        break;
      case 8:
        result = result && getGeoPointValue()
            .equals(other.getGeoPointValue());
        break;
      case 9:
        result = result && getArrayValue()
            .equals(other.getArrayValue());
        break;
      case 6:
        result = result && getMapValue()
            .equals(other.getMapValue());
        break;
      case 0:
      default:
    }
    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();
    switch (valueTypeCase_) {
      case 11:
        hash = (37 * hash) + NULL_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + getNullValueValue();
        break;
      case 1:
        hash = (37 * hash) + BOOLEAN_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
            getBooleanValue());
        break;
      case 2:
        hash = (37 * hash) + INTEGER_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
            getIntegerValue());
        break;
      case 3:
        hash = (37 * hash) + DOUBLE_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
            java.lang.Double.doubleToLongBits(getDoubleValue()));
        break;
      case 10:
        hash = (37 * hash) + TIMESTAMP_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + getTimestampValue().hashCode();
        break;
      case 17:
        hash = (37 * hash) + STRING_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + getStringValue().hashCode();
        break;
      case 18:
        hash = (37 * hash) + BYTES_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + getBytesValue().hashCode();
        break;
      case 5:
        hash = (37 * hash) + REFERENCE_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + getReferenceValue().hashCode();
        break;
      case 8:
        hash = (37 * hash) + GEO_POINT_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + getGeoPointValue().hashCode();
        break;
      case 9:
        hash = (37 * hash) + ARRAY_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + getArrayValue().hashCode();
        break;
      case 6:
        hash = (37 * hash) + MAP_VALUE_FIELD_NUMBER;
        hash = (53 * hash) + getMapValue().hashCode();
        break;
      case 0:
      default:
    }
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.firestore.v1beta1.Value parseFrom(
      java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.firestore.v1beta1.Value parseFrom(
      java.nio.ByteBuffer data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.firestore.v1beta1.Value parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.firestore.v1beta1.Value 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.firestore.v1beta1.Value parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.firestore.v1beta1.Value parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.firestore.v1beta1.Value parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.firestore.v1beta1.Value 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.firestore.v1beta1.Value parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static com.google.firestore.v1beta1.Value 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.firestore.v1beta1.Value parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.firestore.v1beta1.Value 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.firestore.v1beta1.Value 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>
   * A message that can hold any of the supported value types.
   * </pre>
   *
   * Protobuf type {@code google.firestore.v1beta1.Value}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:google.firestore.v1beta1.Value)
      com.google.firestore.v1beta1.ValueOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return com.google.firestore.v1beta1.DocumentProto.internal_static_google_firestore_v1beta1_Value_descriptor;
    }

    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.firestore.v1beta1.DocumentProto.internal_static_google_firestore_v1beta1_Value_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.firestore.v1beta1.Value.class, com.google.firestore.v1beta1.Value.Builder.class);
    }

    // Construct using com.google.firestore.v1beta1.Value.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
      }
    }
    public Builder clear() {
      super.clear();
      valueTypeCase_ = 0;
      valueType_ = null;
      return this;
    }

    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return com.google.firestore.v1beta1.DocumentProto.internal_static_google_firestore_v1beta1_Value_descriptor;
    }

    public com.google.firestore.v1beta1.Value getDefaultInstanceForType() {
      return com.google.firestore.v1beta1.Value.getDefaultInstance();
    }

    public com.google.firestore.v1beta1.Value build() {
      com.google.firestore.v1beta1.Value result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    public com.google.firestore.v1beta1.Value buildPartial() {
      com.google.firestore.v1beta1.Value result = new com.google.firestore.v1beta1.Value(this);
      if (valueTypeCase_ == 11) {
        result.valueType_ = valueType_;
      }
      if (valueTypeCase_ == 1) {
        result.valueType_ = valueType_;
      }
      if (valueTypeCase_ == 2) {
        result.valueType_ = valueType_;
      }
      if (valueTypeCase_ == 3) {
        result.valueType_ = valueType_;
      }
      if (valueTypeCase_ == 10) {
        if (timestampValueBuilder_ == null) {
          result.valueType_ = valueType_;
        } else {
          result.valueType_ = timestampValueBuilder_.build();
        }
      }
      if (valueTypeCase_ == 17) {
        result.valueType_ = valueType_;
      }
      if (valueTypeCase_ == 18) {
        result.valueType_ = valueType_;
      }
      if (valueTypeCase_ == 5) {
        result.valueType_ = valueType_;
      }
      if (valueTypeCase_ == 8) {
        if (geoPointValueBuilder_ == null) {
          result.valueType_ = valueType_;
        } else {
          result.valueType_ = geoPointValueBuilder_.build();
        }
      }
      if (valueTypeCase_ == 9) {
        if (arrayValueBuilder_ == null) {
          result.valueType_ = valueType_;
        } else {
          result.valueType_ = arrayValueBuilder_.build();
        }
      }
      if (valueTypeCase_ == 6) {
        if (mapValueBuilder_ == null) {
          result.valueType_ = valueType_;
        } else {
          result.valueType_ = mapValueBuilder_.build();
        }
      }
      result.valueTypeCase_ = valueTypeCase_;
      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.firestore.v1beta1.Value) {
        return mergeFrom((com.google.firestore.v1beta1.Value)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.firestore.v1beta1.Value other) {
      if (other == com.google.firestore.v1beta1.Value.getDefaultInstance()) return this;
      switch (other.getValueTypeCase()) {
        case NULL_VALUE: {
          setNullValueValue(other.getNullValueValue());
          break;
        }
        case BOOLEAN_VALUE: {
          setBooleanValue(other.getBooleanValue());
          break;
        }
        case INTEGER_VALUE: {
          setIntegerValue(other.getIntegerValue());
          break;
        }
        case DOUBLE_VALUE: {
          setDoubleValue(other.getDoubleValue());
          break;
        }
        case TIMESTAMP_VALUE: {
          mergeTimestampValue(other.getTimestampValue());
          break;
        }
        case STRING_VALUE: {
          valueTypeCase_ = 17;
          valueType_ = other.valueType_;
          onChanged();
          break;
        }
        case BYTES_VALUE: {
          setBytesValue(other.getBytesValue());
          break;
        }
        case REFERENCE_VALUE: {
          valueTypeCase_ = 5;
          valueType_ = other.valueType_;
          onChanged();
          break;
        }
        case GEO_POINT_VALUE: {
          mergeGeoPointValue(other.getGeoPointValue());
          break;
        }
        case ARRAY_VALUE: {
          mergeArrayValue(other.getArrayValue());
          break;
        }
        case MAP_VALUE: {
          mergeMapValue(other.getMapValue());
          break;
        }
        case VALUETYPE_NOT_SET: {
          break;
        }
      }
      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.firestore.v1beta1.Value parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (com.google.firestore.v1beta1.Value) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }
    private int valueTypeCase_ = 0;
    private java.lang.Object valueType_;
    public ValueTypeCase
        getValueTypeCase() {
      return ValueTypeCase.forNumber(
          valueTypeCase_);
    }

    public Builder clearValueType() {
      valueTypeCase_ = 0;
      valueType_ = null;
      onChanged();
      return this;
    }


    /**
     * <pre>
     * A null value.
     * </pre>
     *
     * <code>.google.protobuf.NullValue null_value = 11;</code>
     */
    public int getNullValueValue() {
      if (valueTypeCase_ == 11) {
        return ((java.lang.Integer) valueType_).intValue();
      }
      return 0;
    }
    /**
     * <pre>
     * A null value.
     * </pre>
     *
     * <code>.google.protobuf.NullValue null_value = 11;</code>
     */
    public Builder setNullValueValue(int value) {
      valueTypeCase_ = 11;
      valueType_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * A null value.
     * </pre>
     *
     * <code>.google.protobuf.NullValue null_value = 11;</code>
     */
    public com.google.protobuf.NullValue getNullValue() {
      if (valueTypeCase_ == 11) {
        com.google.protobuf.NullValue result = com.google.protobuf.NullValue.valueOf(
            (java.lang.Integer) valueType_);
        return result == null ? com.google.protobuf.NullValue.UNRECOGNIZED : result;
      }
      return com.google.protobuf.NullValue.NULL_VALUE;
    }
    /**
     * <pre>
     * A null value.
     * </pre>
     *
     * <code>.google.protobuf.NullValue null_value = 11;</code>
     */
    public Builder setNullValue(com.google.protobuf.NullValue value) {
      if (value == null) {
        throw new NullPointerException();
      }
      valueTypeCase_ = 11;
      valueType_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     * <pre>
     * A null value.
     * </pre>
     *
     * <code>.google.protobuf.NullValue null_value = 11;</code>
     */
    public Builder clearNullValue() {
      if (valueTypeCase_ == 11) {
        valueTypeCase_ = 0;
        valueType_ = null;
        onChanged();
      }
      return this;
    }

    /**
     * <pre>
     * A boolean value.
     * </pre>
     *
     * <code>bool boolean_value = 1;</code>
     */
    public boolean getBooleanValue() {
      if (valueTypeCase_ == 1) {
        return (java.lang.Boolean) valueType_;
      }
      return false;
    }
    /**
     * <pre>
     * A boolean value.
     * </pre>
     *
     * <code>bool boolean_value = 1;</code>
     */
    public Builder setBooleanValue(boolean value) {
      valueTypeCase_ = 1;
      valueType_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * A boolean value.
     * </pre>
     *
     * <code>bool boolean_value = 1;</code>
     */
    public Builder clearBooleanValue() {
      if (valueTypeCase_ == 1) {
        valueTypeCase_ = 0;
        valueType_ = null;
        onChanged();
      }
      return this;
    }

    /**
     * <pre>
     * An integer value.
     * </pre>
     *
     * <code>int64 integer_value = 2;</code>
     */
    public long getIntegerValue() {
      if (valueTypeCase_ == 2) {
        return (java.lang.Long) valueType_;
      }
      return 0L;
    }
    /**
     * <pre>
     * An integer value.
     * </pre>
     *
     * <code>int64 integer_value = 2;</code>
     */
    public Builder setIntegerValue(long value) {
      valueTypeCase_ = 2;
      valueType_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * An integer value.
     * </pre>
     *
     * <code>int64 integer_value = 2;</code>
     */
    public Builder clearIntegerValue() {
      if (valueTypeCase_ == 2) {
        valueTypeCase_ = 0;
        valueType_ = null;
        onChanged();
      }
      return this;
    }

    /**
     * <pre>
     * A double value.
     * </pre>
     *
     * <code>double double_value = 3;</code>
     */
    public double getDoubleValue() {
      if (valueTypeCase_ == 3) {
        return (java.lang.Double) valueType_;
      }
      return 0D;
    }
    /**
     * <pre>
     * A double value.
     * </pre>
     *
     * <code>double double_value = 3;</code>
     */
    public Builder setDoubleValue(double value) {
      valueTypeCase_ = 3;
      valueType_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * A double value.
     * </pre>
     *
     * <code>double double_value = 3;</code>
     */
    public Builder clearDoubleValue() {
      if (valueTypeCase_ == 3) {
        valueTypeCase_ = 0;
        valueType_ = null;
        onChanged();
      }
      return this;
    }

    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder> timestampValueBuilder_;
    /**
     * <pre>
     * A timestamp value.
     * Precise only to microseconds. When stored, any additional precision is
     * rounded down.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
     */
    public boolean hasTimestampValue() {
      return valueTypeCase_ == 10;
    }
    /**
     * <pre>
     * A timestamp value.
     * Precise only to microseconds. When stored, any additional precision is
     * rounded down.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
     */
    public com.google.protobuf.Timestamp getTimestampValue() {
      if (timestampValueBuilder_ == null) {
        if (valueTypeCase_ == 10) {
          return (com.google.protobuf.Timestamp) valueType_;
        }
        return com.google.protobuf.Timestamp.getDefaultInstance();
      } else {
        if (valueTypeCase_ == 10) {
          return timestampValueBuilder_.getMessage();
        }
        return com.google.protobuf.Timestamp.getDefaultInstance();
      }
    }
    /**
     * <pre>
     * A timestamp value.
     * Precise only to microseconds. When stored, any additional precision is
     * rounded down.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
     */
    public Builder setTimestampValue(com.google.protobuf.Timestamp value) {
      if (timestampValueBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        valueType_ = value;
        onChanged();
      } else {
        timestampValueBuilder_.setMessage(value);
      }
      valueTypeCase_ = 10;
      return this;
    }
    /**
     * <pre>
     * A timestamp value.
     * Precise only to microseconds. When stored, any additional precision is
     * rounded down.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
     */
    public Builder setTimestampValue(
        com.google.protobuf.Timestamp.Builder builderForValue) {
      if (timestampValueBuilder_ == null) {
        valueType_ = builderForValue.build();
        onChanged();
      } else {
        timestampValueBuilder_.setMessage(builderForValue.build());
      }
      valueTypeCase_ = 10;
      return this;
    }
    /**
     * <pre>
     * A timestamp value.
     * Precise only to microseconds. When stored, any additional precision is
     * rounded down.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
     */
    public Builder mergeTimestampValue(com.google.protobuf.Timestamp value) {
      if (timestampValueBuilder_ == null) {
        if (valueTypeCase_ == 10 &&
            valueType_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
          valueType_ = com.google.protobuf.Timestamp.newBuilder((com.google.protobuf.Timestamp) valueType_)
              .mergeFrom(value).buildPartial();
        } else {
          valueType_ = value;
        }
        onChanged();
      } else {
        if (valueTypeCase_ == 10) {
          timestampValueBuilder_.mergeFrom(value);
        }
        timestampValueBuilder_.setMessage(value);
      }
      valueTypeCase_ = 10;
      return this;
    }
    /**
     * <pre>
     * A timestamp value.
     * Precise only to microseconds. When stored, any additional precision is
     * rounded down.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
     */
    public Builder clearTimestampValue() {
      if (timestampValueBuilder_ == null) {
        if (valueTypeCase_ == 10) {
          valueTypeCase_ = 0;
          valueType_ = null;
          onChanged();
        }
      } else {
        if (valueTypeCase_ == 10) {
          valueTypeCase_ = 0;
          valueType_ = null;
        }
        timestampValueBuilder_.clear();
      }
      return this;
    }
    /**
     * <pre>
     * A timestamp value.
     * Precise only to microseconds. When stored, any additional precision is
     * rounded down.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
     */
    public com.google.protobuf.Timestamp.Builder getTimestampValueBuilder() {
      return getTimestampValueFieldBuilder().getBuilder();
    }
    /**
     * <pre>
     * A timestamp value.
     * Precise only to microseconds. When stored, any additional precision is
     * rounded down.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
     */
    public com.google.protobuf.TimestampOrBuilder getTimestampValueOrBuilder() {
      if ((valueTypeCase_ == 10) && (timestampValueBuilder_ != null)) {
        return timestampValueBuilder_.getMessageOrBuilder();
      } else {
        if (valueTypeCase_ == 10) {
          return (com.google.protobuf.Timestamp) valueType_;
        }
        return com.google.protobuf.Timestamp.getDefaultInstance();
      }
    }
    /**
     * <pre>
     * A timestamp value.
     * Precise only to microseconds. When stored, any additional precision is
     * rounded down.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp timestamp_value = 10;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder> 
        getTimestampValueFieldBuilder() {
      if (timestampValueBuilder_ == null) {
        if (!(valueTypeCase_ == 10)) {
          valueType_ = com.google.protobuf.Timestamp.getDefaultInstance();
        }
        timestampValueBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder>(
                (com.google.protobuf.Timestamp) valueType_,
                getParentForChildren(),
                isClean());
        valueType_ = null;
      }
      valueTypeCase_ = 10;
      onChanged();;
      return timestampValueBuilder_;
    }

    /**
     * <pre>
     * A string value.
     * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
     * Only the first 1,500 bytes of the UTF-8 representation are considered by
     * queries.
     * </pre>
     *
     * <code>string string_value = 17;</code>
     */
    public java.lang.String getStringValue() {
      java.lang.Object ref = "";
      if (valueTypeCase_ == 17) {
        ref = valueType_;
      }
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs =
            (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        if (valueTypeCase_ == 17) {
          valueType_ = s;
        }
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     * <pre>
     * A string value.
     * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
     * Only the first 1,500 bytes of the UTF-8 representation are considered by
     * queries.
     * </pre>
     *
     * <code>string string_value = 17;</code>
     */
    public com.google.protobuf.ByteString
        getStringValueBytes() {
      java.lang.Object ref = "";
      if (valueTypeCase_ == 17) {
        ref = valueType_;
      }
      if (ref instanceof String) {
        com.google.protobuf.ByteString b = 
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        if (valueTypeCase_ == 17) {
          valueType_ = b;
        }
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     * <pre>
     * A string value.
     * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
     * Only the first 1,500 bytes of the UTF-8 representation are considered by
     * queries.
     * </pre>
     *
     * <code>string string_value = 17;</code>
     */
    public Builder setStringValue(
        java.lang.String value) {
      if (value == null) {
    throw new NullPointerException();
  }
  valueTypeCase_ = 17;
      valueType_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * A string value.
     * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
     * Only the first 1,500 bytes of the UTF-8 representation are considered by
     * queries.
     * </pre>
     *
     * <code>string string_value = 17;</code>
     */
    public Builder clearStringValue() {
      if (valueTypeCase_ == 17) {
        valueTypeCase_ = 0;
        valueType_ = null;
        onChanged();
      }
      return this;
    }
    /**
     * <pre>
     * A string value.
     * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
     * Only the first 1,500 bytes of the UTF-8 representation are considered by
     * queries.
     * </pre>
     *
     * <code>string string_value = 17;</code>
     */
    public Builder setStringValueBytes(
        com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }
  checkByteStringIsUtf8(value);
      valueTypeCase_ = 17;
      valueType_ = value;
      onChanged();
      return this;
    }

    /**
     * <pre>
     * A bytes value.
     * Must not exceed 1 MiB - 89 bytes.
     * Only the first 1,500 bytes are considered by queries.
     * </pre>
     *
     * <code>bytes bytes_value = 18;</code>
     */
    public com.google.protobuf.ByteString getBytesValue() {
      if (valueTypeCase_ == 18) {
        return (com.google.protobuf.ByteString) valueType_;
      }
      return com.google.protobuf.ByteString.EMPTY;
    }
    /**
     * <pre>
     * A bytes value.
     * Must not exceed 1 MiB - 89 bytes.
     * Only the first 1,500 bytes are considered by queries.
     * </pre>
     *
     * <code>bytes bytes_value = 18;</code>
     */
    public Builder setBytesValue(com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }
  valueTypeCase_ = 18;
      valueType_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * A bytes value.
     * Must not exceed 1 MiB - 89 bytes.
     * Only the first 1,500 bytes are considered by queries.
     * </pre>
     *
     * <code>bytes bytes_value = 18;</code>
     */
    public Builder clearBytesValue() {
      if (valueTypeCase_ == 18) {
        valueTypeCase_ = 0;
        valueType_ = null;
        onChanged();
      }
      return this;
    }

    /**
     * <pre>
     * A reference to a document. For example:
     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
     * </pre>
     *
     * <code>string reference_value = 5;</code>
     */
    public java.lang.String getReferenceValue() {
      java.lang.Object ref = "";
      if (valueTypeCase_ == 5) {
        ref = valueType_;
      }
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs =
            (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        if (valueTypeCase_ == 5) {
          valueType_ = s;
        }
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     * <pre>
     * A reference to a document. For example:
     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
     * </pre>
     *
     * <code>string reference_value = 5;</code>
     */
    public com.google.protobuf.ByteString
        getReferenceValueBytes() {
      java.lang.Object ref = "";
      if (valueTypeCase_ == 5) {
        ref = valueType_;
      }
      if (ref instanceof String) {
        com.google.protobuf.ByteString b = 
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        if (valueTypeCase_ == 5) {
          valueType_ = b;
        }
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     * <pre>
     * A reference to a document. For example:
     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
     * </pre>
     *
     * <code>string reference_value = 5;</code>
     */
    public Builder setReferenceValue(
        java.lang.String value) {
      if (value == null) {
    throw new NullPointerException();
  }
  valueTypeCase_ = 5;
      valueType_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * A reference to a document. For example:
     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
     * </pre>
     *
     * <code>string reference_value = 5;</code>
     */
    public Builder clearReferenceValue() {
      if (valueTypeCase_ == 5) {
        valueTypeCase_ = 0;
        valueType_ = null;
        onChanged();
      }
      return this;
    }
    /**
     * <pre>
     * A reference to a document. For example:
     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
     * </pre>
     *
     * <code>string reference_value = 5;</code>
     */
    public Builder setReferenceValueBytes(
        com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }
  checkByteStringIsUtf8(value);
      valueTypeCase_ = 5;
      valueType_ = value;
      onChanged();
      return this;
    }

    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.type.LatLng, com.google.type.LatLng.Builder, com.google.type.LatLngOrBuilder> geoPointValueBuilder_;
    /**
     * <pre>
     * A geo point value representing a point on the surface of Earth.
     * </pre>
     *
     * <code>.google.type.LatLng geo_point_value = 8;</code>
     */
    public boolean hasGeoPointValue() {
      return valueTypeCase_ == 8;
    }
    /**
     * <pre>
     * A geo point value representing a point on the surface of Earth.
     * </pre>
     *
     * <code>.google.type.LatLng geo_point_value = 8;</code>
     */
    public com.google.type.LatLng getGeoPointValue() {
      if (geoPointValueBuilder_ == null) {
        if (valueTypeCase_ == 8) {
          return (com.google.type.LatLng) valueType_;
        }
        return com.google.type.LatLng.getDefaultInstance();
      } else {
        if (valueTypeCase_ == 8) {
          return geoPointValueBuilder_.getMessage();
        }
        return com.google.type.LatLng.getDefaultInstance();
      }
    }
    /**
     * <pre>
     * A geo point value representing a point on the surface of Earth.
     * </pre>
     *
     * <code>.google.type.LatLng geo_point_value = 8;</code>
     */
    public Builder setGeoPointValue(com.google.type.LatLng value) {
      if (geoPointValueBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        valueType_ = value;
        onChanged();
      } else {
        geoPointValueBuilder_.setMessage(value);
      }
      valueTypeCase_ = 8;
      return this;
    }
    /**
     * <pre>
     * A geo point value representing a point on the surface of Earth.
     * </pre>
     *
     * <code>.google.type.LatLng geo_point_value = 8;</code>
     */
    public Builder setGeoPointValue(
        com.google.type.LatLng.Builder builderForValue) {
      if (geoPointValueBuilder_ == null) {
        valueType_ = builderForValue.build();
        onChanged();
      } else {
        geoPointValueBuilder_.setMessage(builderForValue.build());
      }
      valueTypeCase_ = 8;
      return this;
    }
    /**
     * <pre>
     * A geo point value representing a point on the surface of Earth.
     * </pre>
     *
     * <code>.google.type.LatLng geo_point_value = 8;</code>
     */
    public Builder mergeGeoPointValue(com.google.type.LatLng value) {
      if (geoPointValueBuilder_ == null) {
        if (valueTypeCase_ == 8 &&
            valueType_ != com.google.type.LatLng.getDefaultInstance()) {
          valueType_ = com.google.type.LatLng.newBuilder((com.google.type.LatLng) valueType_)
              .mergeFrom(value).buildPartial();
        } else {
          valueType_ = value;
        }
        onChanged();
      } else {
        if (valueTypeCase_ == 8) {
          geoPointValueBuilder_.mergeFrom(value);
        }
        geoPointValueBuilder_.setMessage(value);
      }
      valueTypeCase_ = 8;
      return this;
    }
    /**
     * <pre>
     * A geo point value representing a point on the surface of Earth.
     * </pre>
     *
     * <code>.google.type.LatLng geo_point_value = 8;</code>
     */
    public Builder clearGeoPointValue() {
      if (geoPointValueBuilder_ == null) {
        if (valueTypeCase_ == 8) {
          valueTypeCase_ = 0;
          valueType_ = null;
          onChanged();
        }
      } else {
        if (valueTypeCase_ == 8) {
          valueTypeCase_ = 0;
          valueType_ = null;
        }
        geoPointValueBuilder_.clear();
      }
      return this;
    }
    /**
     * <pre>
     * A geo point value representing a point on the surface of Earth.
     * </pre>
     *
     * <code>.google.type.LatLng geo_point_value = 8;</code>
     */
    public com.google.type.LatLng.Builder getGeoPointValueBuilder() {
      return getGeoPointValueFieldBuilder().getBuilder();
    }
    /**
     * <pre>
     * A geo point value representing a point on the surface of Earth.
     * </pre>
     *
     * <code>.google.type.LatLng geo_point_value = 8;</code>
     */
    public com.google.type.LatLngOrBuilder getGeoPointValueOrBuilder() {
      if ((valueTypeCase_ == 8) && (geoPointValueBuilder_ != null)) {
        return geoPointValueBuilder_.getMessageOrBuilder();
      } else {
        if (valueTypeCase_ == 8) {
          return (com.google.type.LatLng) valueType_;
        }
        return com.google.type.LatLng.getDefaultInstance();
      }
    }
    /**
     * <pre>
     * A geo point value representing a point on the surface of Earth.
     * </pre>
     *
     * <code>.google.type.LatLng geo_point_value = 8;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.type.LatLng, com.google.type.LatLng.Builder, com.google.type.LatLngOrBuilder> 
        getGeoPointValueFieldBuilder() {
      if (geoPointValueBuilder_ == null) {
        if (!(valueTypeCase_ == 8)) {
          valueType_ = com.google.type.LatLng.getDefaultInstance();
        }
        geoPointValueBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.google.type.LatLng, com.google.type.LatLng.Builder, com.google.type.LatLngOrBuilder>(
                (com.google.type.LatLng) valueType_,
                getParentForChildren(),
                isClean());
        valueType_ = null;
      }
      valueTypeCase_ = 8;
      onChanged();;
      return geoPointValueBuilder_;
    }

    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.firestore.v1beta1.ArrayValue, com.google.firestore.v1beta1.ArrayValue.Builder, com.google.firestore.v1beta1.ArrayValueOrBuilder> arrayValueBuilder_;
    /**
     * <pre>
     * An array value.
     * Cannot contain another array value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
     */
    public boolean hasArrayValue() {
      return valueTypeCase_ == 9;
    }
    /**
     * <pre>
     * An array value.
     * Cannot contain another array value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
     */
    public com.google.firestore.v1beta1.ArrayValue getArrayValue() {
      if (arrayValueBuilder_ == null) {
        if (valueTypeCase_ == 9) {
          return (com.google.firestore.v1beta1.ArrayValue) valueType_;
        }
        return com.google.firestore.v1beta1.ArrayValue.getDefaultInstance();
      } else {
        if (valueTypeCase_ == 9) {
          return arrayValueBuilder_.getMessage();
        }
        return com.google.firestore.v1beta1.ArrayValue.getDefaultInstance();
      }
    }
    /**
     * <pre>
     * An array value.
     * Cannot contain another array value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
     */
    public Builder setArrayValue(com.google.firestore.v1beta1.ArrayValue value) {
      if (arrayValueBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        valueType_ = value;
        onChanged();
      } else {
        arrayValueBuilder_.setMessage(value);
      }
      valueTypeCase_ = 9;
      return this;
    }
    /**
     * <pre>
     * An array value.
     * Cannot contain another array value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
     */
    public Builder setArrayValue(
        com.google.firestore.v1beta1.ArrayValue.Builder builderForValue) {
      if (arrayValueBuilder_ == null) {
        valueType_ = builderForValue.build();
        onChanged();
      } else {
        arrayValueBuilder_.setMessage(builderForValue.build());
      }
      valueTypeCase_ = 9;
      return this;
    }
    /**
     * <pre>
     * An array value.
     * Cannot contain another array value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
     */
    public Builder mergeArrayValue(com.google.firestore.v1beta1.ArrayValue value) {
      if (arrayValueBuilder_ == null) {
        if (valueTypeCase_ == 9 &&
            valueType_ != com.google.firestore.v1beta1.ArrayValue.getDefaultInstance()) {
          valueType_ = com.google.firestore.v1beta1.ArrayValue.newBuilder((com.google.firestore.v1beta1.ArrayValue) valueType_)
              .mergeFrom(value).buildPartial();
        } else {
          valueType_ = value;
        }
        onChanged();
      } else {
        if (valueTypeCase_ == 9) {
          arrayValueBuilder_.mergeFrom(value);
        }
        arrayValueBuilder_.setMessage(value);
      }
      valueTypeCase_ = 9;
      return this;
    }
    /**
     * <pre>
     * An array value.
     * Cannot contain another array value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
     */
    public Builder clearArrayValue() {
      if (arrayValueBuilder_ == null) {
        if (valueTypeCase_ == 9) {
          valueTypeCase_ = 0;
          valueType_ = null;
          onChanged();
        }
      } else {
        if (valueTypeCase_ == 9) {
          valueTypeCase_ = 0;
          valueType_ = null;
        }
        arrayValueBuilder_.clear();
      }
      return this;
    }
    /**
     * <pre>
     * An array value.
     * Cannot contain another array value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
     */
    public com.google.firestore.v1beta1.ArrayValue.Builder getArrayValueBuilder() {
      return getArrayValueFieldBuilder().getBuilder();
    }
    /**
     * <pre>
     * An array value.
     * Cannot contain another array value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
     */
    public com.google.firestore.v1beta1.ArrayValueOrBuilder getArrayValueOrBuilder() {
      if ((valueTypeCase_ == 9) && (arrayValueBuilder_ != null)) {
        return arrayValueBuilder_.getMessageOrBuilder();
      } else {
        if (valueTypeCase_ == 9) {
          return (com.google.firestore.v1beta1.ArrayValue) valueType_;
        }
        return com.google.firestore.v1beta1.ArrayValue.getDefaultInstance();
      }
    }
    /**
     * <pre>
     * An array value.
     * Cannot contain another array value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.ArrayValue array_value = 9;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.firestore.v1beta1.ArrayValue, com.google.firestore.v1beta1.ArrayValue.Builder, com.google.firestore.v1beta1.ArrayValueOrBuilder> 
        getArrayValueFieldBuilder() {
      if (arrayValueBuilder_ == null) {
        if (!(valueTypeCase_ == 9)) {
          valueType_ = com.google.firestore.v1beta1.ArrayValue.getDefaultInstance();
        }
        arrayValueBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.google.firestore.v1beta1.ArrayValue, com.google.firestore.v1beta1.ArrayValue.Builder, com.google.firestore.v1beta1.ArrayValueOrBuilder>(
                (com.google.firestore.v1beta1.ArrayValue) valueType_,
                getParentForChildren(),
                isClean());
        valueType_ = null;
      }
      valueTypeCase_ = 9;
      onChanged();;
      return arrayValueBuilder_;
    }

    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.firestore.v1beta1.MapValue, com.google.firestore.v1beta1.MapValue.Builder, com.google.firestore.v1beta1.MapValueOrBuilder> mapValueBuilder_;
    /**
     * <pre>
     * A map value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
     */
    public boolean hasMapValue() {
      return valueTypeCase_ == 6;
    }
    /**
     * <pre>
     * A map value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
     */
    public com.google.firestore.v1beta1.MapValue getMapValue() {
      if (mapValueBuilder_ == null) {
        if (valueTypeCase_ == 6) {
          return (com.google.firestore.v1beta1.MapValue) valueType_;
        }
        return com.google.firestore.v1beta1.MapValue.getDefaultInstance();
      } else {
        if (valueTypeCase_ == 6) {
          return mapValueBuilder_.getMessage();
        }
        return com.google.firestore.v1beta1.MapValue.getDefaultInstance();
      }
    }
    /**
     * <pre>
     * A map value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
     */
    public Builder setMapValue(com.google.firestore.v1beta1.MapValue value) {
      if (mapValueBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        valueType_ = value;
        onChanged();
      } else {
        mapValueBuilder_.setMessage(value);
      }
      valueTypeCase_ = 6;
      return this;
    }
    /**
     * <pre>
     * A map value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
     */
    public Builder setMapValue(
        com.google.firestore.v1beta1.MapValue.Builder builderForValue) {
      if (mapValueBuilder_ == null) {
        valueType_ = builderForValue.build();
        onChanged();
      } else {
        mapValueBuilder_.setMessage(builderForValue.build());
      }
      valueTypeCase_ = 6;
      return this;
    }
    /**
     * <pre>
     * A map value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
     */
    public Builder mergeMapValue(com.google.firestore.v1beta1.MapValue value) {
      if (mapValueBuilder_ == null) {
        if (valueTypeCase_ == 6 &&
            valueType_ != com.google.firestore.v1beta1.MapValue.getDefaultInstance()) {
          valueType_ = com.google.firestore.v1beta1.MapValue.newBuilder((com.google.firestore.v1beta1.MapValue) valueType_)
              .mergeFrom(value).buildPartial();
        } else {
          valueType_ = value;
        }
        onChanged();
      } else {
        if (valueTypeCase_ == 6) {
          mapValueBuilder_.mergeFrom(value);
        }
        mapValueBuilder_.setMessage(value);
      }
      valueTypeCase_ = 6;
      return this;
    }
    /**
     * <pre>
     * A map value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
     */
    public Builder clearMapValue() {
      if (mapValueBuilder_ == null) {
        if (valueTypeCase_ == 6) {
          valueTypeCase_ = 0;
          valueType_ = null;
          onChanged();
        }
      } else {
        if (valueTypeCase_ == 6) {
          valueTypeCase_ = 0;
          valueType_ = null;
        }
        mapValueBuilder_.clear();
      }
      return this;
    }
    /**
     * <pre>
     * A map value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
     */
    public com.google.firestore.v1beta1.MapValue.Builder getMapValueBuilder() {
      return getMapValueFieldBuilder().getBuilder();
    }
    /**
     * <pre>
     * A map value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
     */
    public com.google.firestore.v1beta1.MapValueOrBuilder getMapValueOrBuilder() {
      if ((valueTypeCase_ == 6) && (mapValueBuilder_ != null)) {
        return mapValueBuilder_.getMessageOrBuilder();
      } else {
        if (valueTypeCase_ == 6) {
          return (com.google.firestore.v1beta1.MapValue) valueType_;
        }
        return com.google.firestore.v1beta1.MapValue.getDefaultInstance();
      }
    }
    /**
     * <pre>
     * A map value.
     * </pre>
     *
     * <code>.google.firestore.v1beta1.MapValue map_value = 6;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.firestore.v1beta1.MapValue, com.google.firestore.v1beta1.MapValue.Builder, com.google.firestore.v1beta1.MapValueOrBuilder> 
        getMapValueFieldBuilder() {
      if (mapValueBuilder_ == null) {
        if (!(valueTypeCase_ == 6)) {
          valueType_ = com.google.firestore.v1beta1.MapValue.getDefaultInstance();
        }
        mapValueBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.google.firestore.v1beta1.MapValue, com.google.firestore.v1beta1.MapValue.Builder, com.google.firestore.v1beta1.MapValueOrBuilder>(
                (com.google.firestore.v1beta1.MapValue) valueType_,
                getParentForChildren(),
                isClean());
        valueType_ = null;
      }
      valueTypeCase_ = 6;
      onChanged();;
      return mapValueBuilder_;
    }
    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.firestore.v1beta1.Value)
  }

  // @@protoc_insertion_point(class_scope:google.firestore.v1beta1.Value)
  private static final com.google.firestore.v1beta1.Value DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new com.google.firestore.v1beta1.Value();
  }

  public static com.google.firestore.v1beta1.Value getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

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

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

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

  public com.google.firestore.v1beta1.Value getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}

