///
/// JNativeNotificationResponse.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 "NativeNotificationResponse.hpp"

#include "JNativeContent.hpp"
#include "JNativeNotification.hpp"
#include "JNativeNotificationRequest.hpp"
#include "JNativeTrigger.hpp"
#include "JNativeTriggerType.hpp"
#include "NativeContent.hpp"
#include "NativeNotification.hpp"
#include "NativeNotificationRequest.hpp"
#include "NativeTrigger.hpp"
#include "NativeTriggerType.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 "NativeNotificationResponse" and the Kotlin data class "NativeNotificationResponse".
   */
  struct JNativeNotificationResponse final: public jni::JavaClass<JNativeNotificationResponse> {
  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/one/NativeNotificationResponse;";

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeNotificationResponse by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeNotificationResponse toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldNotification = clazz->getField<JNativeNotification>("notification");
      jni::local_ref<JNativeNotification> notification = this->getFieldValue(fieldNotification);
      static const auto fieldActionIdentifier = clazz->getField<jni::JString>("actionIdentifier");
      jni::local_ref<jni::JString> actionIdentifier = this->getFieldValue(fieldActionIdentifier);
      static const auto fieldUserText = clazz->getField<jni::JString>("userText");
      jni::local_ref<jni::JString> userText = this->getFieldValue(fieldUserText);
      return NativeNotificationResponse(
        notification->toCpp(),
        actionIdentifier->toStdString(),
        userText != nullptr ? std::make_optional(userText->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<JNativeNotificationResponse::javaobject> fromCpp(const NativeNotificationResponse& value) {
      using JSignature = JNativeNotificationResponse(jni::alias_ref<JNativeNotification>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JNativeNotification::fromCpp(value.notification),
        jni::make_jstring(value.actionIdentifier),
        value.userText.has_value() ? jni::make_jstring(value.userText.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
