///
/// JNativeLiveActivityAttributes.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 "NativeLiveActivityAttributes.hpp"

#include <string>
#include <unordered_map>

namespace margelo::nitro::liveactivitykit {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeLiveActivityAttributes by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeLiveActivityAttributes toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldName = clazz->getField<jni::JString>("name");
      jni::local_ref<jni::JString> name = this->getFieldValue(fieldName);
      static const auto fieldExtra = clazz->getField<jni::JMap<jni::JString, jni::JString>>("extra");
      jni::local_ref<jni::JMap<jni::JString, jni::JString>> extra = this->getFieldValue(fieldExtra);
      return NativeLiveActivityAttributes(
        name->toStdString(),
        [&]() {
          std::unordered_map<std::string, std::string> __map;
          __map.reserve(extra->size());
          for (const auto& __entry : *extra) {
            __map.emplace(__entry.first->toStdString(), __entry.second->toStdString());
          }
          return __map;
        }()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JNativeLiveActivityAttributes::javaobject> fromCpp(const NativeLiveActivityAttributes& value) {
      using JSignature = JNativeLiveActivityAttributes(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JMap<jni::JString, jni::JString>>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.name),
        [&]() -> jni::local_ref<jni::JMap<jni::JString, jni::JString>> {
          auto __map = jni::JHashMap<jni::JString, jni::JString>::create(value.extra.size());
          for (const auto& __entry : value.extra) {
            __map->put(jni::make_jstring(__entry.first), jni::make_jstring(__entry.second));
          }
          return __map;
        }()
      );
    }
  };

} // namespace margelo::nitro::liveactivitykit
