///
/// JSensitiveInfoGetRequest.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 "SensitiveInfoGetRequest.hpp"

#include "AccessControl.hpp"
#include "AuthenticationPrompt.hpp"
#include "JAccessControl.hpp"
#include "JAuthenticationPrompt.hpp"
#include <optional>
#include <string>

namespace margelo::nitro::sensitiveinfo {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct SensitiveInfoGetRequest by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    SensitiveInfoGetRequest toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldKey = clazz->getField<jni::JString>("key");
      jni::local_ref<jni::JString> key = this->getFieldValue(fieldKey);
      static const auto fieldIncludeValue = clazz->getField<jni::JBoolean>("includeValue");
      jni::local_ref<jni::JBoolean> includeValue = this->getFieldValue(fieldIncludeValue);
      static const auto fieldService = clazz->getField<jni::JString>("service");
      jni::local_ref<jni::JString> service = this->getFieldValue(fieldService);
      static const auto fieldIosSynchronizable = clazz->getField<jni::JBoolean>("iosSynchronizable");
      jni::local_ref<jni::JBoolean> iosSynchronizable = this->getFieldValue(fieldIosSynchronizable);
      static const auto fieldKeychainGroup = clazz->getField<jni::JString>("keychainGroup");
      jni::local_ref<jni::JString> keychainGroup = this->getFieldValue(fieldKeychainGroup);
      static const auto fieldAccessControl = clazz->getField<JAccessControl>("accessControl");
      jni::local_ref<JAccessControl> accessControl = this->getFieldValue(fieldAccessControl);
      static const auto fieldAuthenticationPrompt = clazz->getField<JAuthenticationPrompt>("authenticationPrompt");
      jni::local_ref<JAuthenticationPrompt> authenticationPrompt = this->getFieldValue(fieldAuthenticationPrompt);
      return SensitiveInfoGetRequest(
        key->toStdString(),
        includeValue != nullptr ? std::make_optional(static_cast<bool>(includeValue->value())) : std::nullopt,
        service != nullptr ? std::make_optional(service->toStdString()) : std::nullopt,
        iosSynchronizable != nullptr ? std::make_optional(static_cast<bool>(iosSynchronizable->value())) : std::nullopt,
        keychainGroup != nullptr ? std::make_optional(keychainGroup->toStdString()) : std::nullopt,
        accessControl != nullptr ? std::make_optional(accessControl->toCpp()) : std::nullopt,
        authenticationPrompt != nullptr ? std::make_optional(authenticationPrompt->toCpp()) : 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<JSensitiveInfoGetRequest::javaobject> fromCpp(const SensitiveInfoGetRequest& value) {
      using JSignature = JSensitiveInfoGetRequest(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JString>, jni::alias_ref<JAccessControl>, jni::alias_ref<JAuthenticationPrompt>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.key),
        value.includeValue.has_value() ? jni::JBoolean::valueOf(value.includeValue.value()) : nullptr,
        value.service.has_value() ? jni::make_jstring(value.service.value()) : nullptr,
        value.iosSynchronizable.has_value() ? jni::JBoolean::valueOf(value.iosSynchronizable.value()) : nullptr,
        value.keychainGroup.has_value() ? jni::make_jstring(value.keychainGroup.value()) : nullptr,
        value.accessControl.has_value() ? JAccessControl::fromCpp(value.accessControl.value()) : nullptr,
        value.authenticationPrompt.has_value() ? JAuthenticationPrompt::fromCpp(value.authenticationPrompt.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::sensitiveinfo
