class UserDataWriter {

  Object convertValue(Value value) {
    switch (typeOrder(value)) {
      case TYPE_ORDER_MAP:
        return convertObject(value.getMapValue().getFieldsMap());
      case TYPE_ORDER_ARRAY:
        return convertArray(value.getArrayValue());
      case TYPE_ORDER_REFERENCE:
        return convertReference(value);
      case TYPE_ORDER_TIMESTAMP:
        return convertTimestamp(value.getTimestampValue());
      case TYPE_ORDER_SERVER_TIMESTAMP:
        return convertServerTimestamp(value);
      case TYPE_ORDER_NULL:
        return null;
      case TYPE_ORDER_BOOLEAN:
        return value.getBooleanValue();
      case TYPE_ORDER_NUMBER:
        return value.getValueTypeCase().equals(Value.ValueTypeCase.INTEGER_VALUE)
            ? (Object) value.getIntegerValue() // Cast to Object to prevent type coercion to double
            : (Object) value.getDoubleValue();
      case TYPE_ORDER_STRING:
        return value.getStringValue();
      case TYPE_ORDER_BLOB:
        return Blob.fromByteString(value.getBytesValue());
      case TYPE_ORDER_GEOPOINT:
        return new GeoPoint(
            value.getGeoPointValue().getLatitude(), value.getGeoPointValue().getLongitude());
      default:
        throw fail("Unknown value type: " + value.getValueTypeCase());
    }
  }

    UserDataWriter(
      FirebaseFirestore firestore,
      boolean timestampsInSnapshots,
      DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior);

}