///
/// JAuthenticationPrompt.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 "AuthenticationPrompt.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::sensitiveinfo {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct AuthenticationPrompt by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    AuthenticationPrompt 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 fieldDescription = clazz->getField<jni::JString>("description");
      jni::local_ref<jni::JString> description = this->getFieldValue(fieldDescription);
      static const auto fieldCancel = clazz->getField<jni::JString>("cancel");
      jni::local_ref<jni::JString> cancel = this->getFieldValue(fieldCancel);
      return AuthenticationPrompt(
        title->toStdString(),
        subtitle != nullptr ? std::make_optional(subtitle->toStdString()) : std::nullopt,
        description != nullptr ? std::make_optional(description->toStdString()) : std::nullopt,
        cancel != nullptr ? std::make_optional(cancel->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<JAuthenticationPrompt::javaobject> fromCpp(const AuthenticationPrompt& value) {
      using JSignature = JAuthenticationPrompt(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, 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,
        jni::make_jstring(value.title),
        value.subtitle.has_value() ? jni::make_jstring(value.subtitle.value()) : nullptr,
        value.description.has_value() ? jni::make_jstring(value.description.value()) : nullptr,
        value.cancel.has_value() ? jni::make_jstring(value.cancel.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::sensitiveinfo
