///
/// JNativeContent.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 "NativeContent.hpp"

#include <NitroModules/AnyMap.hpp>
#include <NitroModules/JAnyMap.hpp>
#include <optional>
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeContent by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeContent toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldTitle = clazz->getField<jni::JString>("title");
      jni::local_ref<jni::JString> title = this->getFieldValue(fieldTitle);
      static const auto fieldSubtitle = clazz->getField<jni::JString>("subtitle");
      jni::local_ref<jni::JString> subtitle = this->getFieldValue(fieldSubtitle);
      static const auto fieldBody = clazz->getField<jni::JString>("body");
      jni::local_ref<jni::JString> body = this->getFieldValue(fieldBody);
      static const auto fieldData = clazz->getField<JAnyMap::javaobject>("data");
      jni::local_ref<JAnyMap::javaobject> data = this->getFieldValue(fieldData);
      static const auto fieldSound = clazz->getField<jboolean>("sound");
      jboolean sound = this->getFieldValue(fieldSound);
      static const auto fieldBadge = clazz->getField<jni::JDouble>("badge");
      jni::local_ref<jni::JDouble> badge = this->getFieldValue(fieldBadge);
      static const auto fieldCategoryIdentifier = clazz->getField<jni::JString>("categoryIdentifier");
      jni::local_ref<jni::JString> categoryIdentifier = this->getFieldValue(fieldCategoryIdentifier);
      return NativeContent(
        title != nullptr ? std::make_optional(title->toStdString()) : std::nullopt,
        subtitle != nullptr ? std::make_optional(subtitle->toStdString()) : std::nullopt,
        body != nullptr ? std::make_optional(body->toStdString()) : std::nullopt,
        data->cthis()->getMap(),
        static_cast<bool>(sound),
        badge != nullptr ? std::make_optional(badge->value()) : std::nullopt,
        categoryIdentifier != nullptr ? std::make_optional(categoryIdentifier->toStdString()) : 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<JNativeContent::javaobject> fromCpp(const NativeContent& value) {
      using JSignature = JNativeContent(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<JAnyMap::javaobject>, jboolean, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.title.has_value() ? jni::make_jstring(value.title.value()) : nullptr,
        value.subtitle.has_value() ? jni::make_jstring(value.subtitle.value()) : nullptr,
        value.body.has_value() ? jni::make_jstring(value.body.value()) : nullptr,
        JAnyMap::create(value.data),
        value.sound,
        value.badge.has_value() ? jni::JDouble::valueOf(value.badge.value()) : nullptr,
        value.categoryIdentifier.has_value() ? jni::make_jstring(value.categoryIdentifier.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
