///
/// JTikTokContent.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "TikTokContent.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::tiktokappevents {

  using namespace facebook;

  /**
   * The C++ JNI bridge between the C++ struct "TikTokContent" and the the Kotlin data class "TikTokContent".
   */
  struct JTikTokContent final: public jni::JavaClass<JTikTokContent> {
  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/tiktokappevents/TikTokContent;";

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct TikTokContent by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    TikTokContent toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldContentId = clazz->getField<jni::JString>("contentId");
      jni::local_ref<jni::JString> contentId = this->getFieldValue(fieldContentId);
      static const auto fieldContentCategory = clazz->getField<jni::JString>("contentCategory");
      jni::local_ref<jni::JString> contentCategory = this->getFieldValue(fieldContentCategory);
      static const auto fieldContentName = clazz->getField<jni::JString>("contentName");
      jni::local_ref<jni::JString> contentName = this->getFieldValue(fieldContentName);
      static const auto fieldBrand = clazz->getField<jni::JString>("brand");
      jni::local_ref<jni::JString> brand = this->getFieldValue(fieldBrand);
      static const auto fieldPrice = clazz->getField<jni::JDouble>("price");
      jni::local_ref<jni::JDouble> price = this->getFieldValue(fieldPrice);
      static const auto fieldQuantity = clazz->getField<jni::JDouble>("quantity");
      jni::local_ref<jni::JDouble> quantity = this->getFieldValue(fieldQuantity);
      return TikTokContent(
        contentId != nullptr ? std::make_optional(contentId->toStdString()) : std::nullopt,
        contentCategory != nullptr ? std::make_optional(contentCategory->toStdString()) : std::nullopt,
        contentName != nullptr ? std::make_optional(contentName->toStdString()) : std::nullopt,
        brand != nullptr ? std::make_optional(brand->toStdString()) : std::nullopt,
        price != nullptr ? std::make_optional(price->value()) : std::nullopt,
        quantity != nullptr ? std::make_optional(quantity->value()) : std::nullopt
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JTikTokContent::javaobject> fromCpp(const TikTokContent& value) {
      using JSignature = JTikTokContent(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.contentId.has_value() ? jni::make_jstring(value.contentId.value()) : nullptr,
        value.contentCategory.has_value() ? jni::make_jstring(value.contentCategory.value()) : nullptr,
        value.contentName.has_value() ? jni::make_jstring(value.contentName.value()) : nullptr,
        value.brand.has_value() ? jni::make_jstring(value.brand.value()) : nullptr,
        value.price.has_value() ? jni::JDouble::valueOf(value.price.value()) : nullptr,
        value.quantity.has_value() ? jni::JDouble::valueOf(value.quantity.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::tiktokappevents
