///
/// JNativeIosPermissionRequest.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 "NativeIosPermissionRequest.hpp"

#include <optional>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeIosPermissionRequest by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeIosPermissionRequest toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldAllowAlert = clazz->getField<jni::JBoolean>("allowAlert");
      jni::local_ref<jni::JBoolean> allowAlert = this->getFieldValue(fieldAllowAlert);
      static const auto fieldAllowBadge = clazz->getField<jni::JBoolean>("allowBadge");
      jni::local_ref<jni::JBoolean> allowBadge = this->getFieldValue(fieldAllowBadge);
      static const auto fieldAllowSound = clazz->getField<jni::JBoolean>("allowSound");
      jni::local_ref<jni::JBoolean> allowSound = this->getFieldValue(fieldAllowSound);
      static const auto fieldAllowProvisional = clazz->getField<jni::JBoolean>("allowProvisional");
      jni::local_ref<jni::JBoolean> allowProvisional = this->getFieldValue(fieldAllowProvisional);
      return NativeIosPermissionRequest(
        allowAlert != nullptr ? std::make_optional(static_cast<bool>(allowAlert->value())) : std::nullopt,
        allowBadge != nullptr ? std::make_optional(static_cast<bool>(allowBadge->value())) : std::nullopt,
        allowSound != nullptr ? std::make_optional(static_cast<bool>(allowSound->value())) : std::nullopt,
        allowProvisional != nullptr ? std::make_optional(static_cast<bool>(allowProvisional->value())) : 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<JNativeIosPermissionRequest::javaobject> fromCpp(const NativeIosPermissionRequest& value) {
      using JSignature = JNativeIosPermissionRequest(jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.allowAlert.has_value() ? jni::JBoolean::valueOf(value.allowAlert.value()) : nullptr,
        value.allowBadge.has_value() ? jni::JBoolean::valueOf(value.allowBadge.value()) : nullptr,
        value.allowSound.has_value() ? jni::JBoolean::valueOf(value.allowSound.value()) : nullptr,
        value.allowProvisional.has_value() ? jni::JBoolean::valueOf(value.allowProvisional.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
