// Generated by the proto_extras plugin. DO NOT EDIT!
// source: components/optimization_guide/proto/features/content_annotation.proto

#include "components/optimization_guide/proto/features/content_annotation.to_value.h"



#include "base/base64.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "components/optimization_guide/proto/features/common_quality_data.pb.h"
#include "components/optimization_guide/proto/features/common_quality_data.to_value.h"
#include "components/optimization_guide/proto/features/content_annotation.pb.h"
#include "components/optimization_guide/proto/model_quality_metadata.pb.h"
#include "components/optimization_guide/proto/model_quality_metadata.to_value.h"
#include "components/proto_extras/proto_extras_lib.h"


namespace optimization_guide {
namespace proto {
void MaybeToValue(const std::optional<ContentAnnotationLoggingData>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const ContentAnnotationLoggingData& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_request()) {
    dict.Set("request", ::optimization_guide::proto::ToValue(message.request()));
  }
  if (message.has_response()) {
    dict.Set("response", ::optimization_guide::proto::ToValue(message.response()));
  }
  if (message.has_model_execution_info()) {
    dict.Set("model_execution_info", ::optimization_guide::proto::ToValue(message.model_execution_info()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<ContentAnnotationRequest>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const ContentAnnotationRequest& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_page_context()) {
    dict.Set("page_context", ::optimization_guide::proto::ToValue(message.page_context()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<ContentAnnotationResponse>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const ContentAnnotationResponse& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_extracted_data()) {
    dict.Set("extracted_data", (message.extracted_data()));
  }
  if (message.has_content_annotation()) {
    dict.Set("content_annotation", ::optimization_guide::proto::ToValue(message.content_annotation()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<ContentAnnotation>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const ContentAnnotation& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_description()) {
    dict.Set("description", (message.description()));
  }
  if (message.has_status()) {
    dict.Set("status", ::optimization_guide::proto::ContentAnnotation_Status_Name(message.status()));
  }
  if (message.has_structured_data()) {
    dict.Set("structured_data", ::optimization_guide::proto::ToValue(message.structured_data()));
  }
  if (!message.supplemental_data().empty()) {
    base::ListValue list;
    for (const auto& value : message.supplemental_data()) {
      list.Append(::optimization_guide::proto::ToValue(value));
    }
    dict.Set("supplemental_data", std::move(list));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<StructuredData>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const StructuredData& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (!message.orders().empty()) {
    base::ListValue list;
    for (const auto& value : message.orders()) {
      list.Append(::optimization_guide::proto::ToValue(value));
    }
    dict.Set("orders", std::move(list));
  }
  if (!message.shipments().empty()) {
    base::ListValue list;
    for (const auto& value : message.shipments()) {
      list.Append(::optimization_guide::proto::ToValue(value));
    }
    dict.Set("shipments", std::move(list));
  }
  if (!message.flight_reservations().empty()) {
    base::ListValue list;
    for (const auto& value : message.flight_reservations()) {
      list.Append(::optimization_guide::proto::ToValue(value));
    }
    dict.Set("flight_reservations", std::move(list));
  }
  if (!message.hotel_bookings().empty()) {
    base::ListValue list;
    for (const auto& value : message.hotel_bookings()) {
      list.Append(::optimization_guide::proto::ToValue(value));
    }
    dict.Set("hotel_bookings", std::move(list));
  }
  if (!message.car_rentals().empty()) {
    base::ListValue list;
    for (const auto& value : message.car_rentals()) {
      list.Append(::optimization_guide::proto::ToValue(value));
    }
    dict.Set("car_rentals", std::move(list));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<Order>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const Order& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_id()) {
    dict.Set("id", (message.id()));
  }
  if (!message.products().empty()) {
    base::ListValue list;
    for (const auto& value : message.products()) {
      list.Append(::optimization_guide::proto::ToValue(value));
    }
    dict.Set("products", std::move(list));
  }
  if (message.has_order_date()) {
    dict.Set("order_date", ::optimization_guide::proto::ToValue(message.order_date()));
  }
  if (message.has_grand_total()) {
    dict.Set("grand_total", static_cast<double>(message.grand_total()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<Product>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const Product& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_name()) {
    dict.Set("name", (message.name()));
  }
  if (message.has_quantity()) {
    dict.Set("quantity", (message.quantity()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<Date>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const Date& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_year()) {
    dict.Set("year", (message.year()));
  }
  if (message.has_month()) {
    dict.Set("month", (message.month()));
  }
  if (message.has_day()) {
    dict.Set("day", (message.day()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<Shipment>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const Shipment& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_associated_order_id()) {
    dict.Set("associated_order_id", (message.associated_order_id()));
  }
  if (message.has_tracking_number()) {
    dict.Set("tracking_number", (message.tracking_number()));
  }
  if (message.has_carrier_name()) {
    dict.Set("carrier_name", (message.carrier_name()));
  }
  if (message.has_delivery_address()) {
    dict.Set("delivery_address", (message.delivery_address()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<FlightReservation>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const FlightReservation& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_confirmation_code()) {
    dict.Set("confirmation_code", (message.confirmation_code()));
  }
  if (message.has_grand_total()) {
    dict.Set("grand_total", static_cast<double>(message.grand_total()));
  }
  if (message.has_flight_number()) {
    dict.Set("flight_number", (message.flight_number()));
  }
  if (message.has_passenger_name()) {
    dict.Set("passenger_name", (message.passenger_name()));
  }
  if (message.has_departure_airport()) {
    dict.Set("departure_airport", (message.departure_airport()));
  }
  if (message.has_arrival_airport()) {
    dict.Set("arrival_airport", (message.arrival_airport()));
  }
  if (message.has_departure_date()) {
    dict.Set("departure_date", ::optimization_guide::proto::ToValue(message.departure_date()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<HotelBooking>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const HotelBooking& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_confirmation_code()) {
    dict.Set("confirmation_code", (message.confirmation_code()));
  }
  if (message.has_grand_total()) {
    dict.Set("grand_total", static_cast<double>(message.grand_total()));
  }
  if (message.has_property_name()) {
    dict.Set("property_name", (message.property_name()));
  }
  if (message.has_check_in_date()) {
    dict.Set("check_in_date", ::optimization_guide::proto::ToValue(message.check_in_date()));
  }
  if (message.has_check_out_date()) {
    dict.Set("check_out_date", ::optimization_guide::proto::ToValue(message.check_out_date()));
  }
  if (message.has_city()) {
    dict.Set("city", (message.city()));
  }
  if (message.has_guest_name()) {
    dict.Set("guest_name", (message.guest_name()));
  }
  if (message.has_number_of_guests()) {
    dict.Set("number_of_guests", (message.number_of_guests()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<CarRental>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const CarRental& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_confirmation_code()) {
    dict.Set("confirmation_code", (message.confirmation_code()));
  }
  if (message.has_grand_total()) {
    dict.Set("grand_total", static_cast<double>(message.grand_total()));
  }
  if (message.has_car_model()) {
    dict.Set("car_model", (message.car_model()));
  }
  if (message.has_guest_name()) {
    dict.Set("guest_name", (message.guest_name()));
  }
  if (message.has_pickup_location_name()) {
    dict.Set("pickup_location_name", (message.pickup_location_name()));
  }
  if (message.has_dropoff_location_name()) {
    dict.Set("dropoff_location_name", (message.dropoff_location_name()));
  }
  if (message.has_pickup_date()) {
    dict.Set("pickup_date", ::optimization_guide::proto::ToValue(message.pickup_date()));
  }
  if (message.has_dropoff_date()) {
    dict.Set("dropoff_date", ::optimization_guide::proto::ToValue(message.dropoff_date()));
  }
  if (message.has_merchant()) {
    dict.Set("merchant", (message.merchant()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<DynamicAttribute>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const DynamicAttribute& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_string_value()) {
    dict.Set("string_value", (message.string_value()));
  }
  if (message.has_number_value()) {
    dict.Set("number_value", static_cast<double>(message.number_value()));
  }
  if (message.has_key()) {
    dict.Set("key", (message.key()));
  }
  return base::Value(std::move(dict));
}
}  // namespace proto
}  // namespace optimization_guide

