///
/// JNativePermissionRequest.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 "NativePermissionRequest.hpp"

#include "JNativeIosPermissionRequest.hpp"
#include "NativeIosPermissionRequest.hpp"
#include <optional>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativePermissionRequest by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativePermissionRequest toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldIos = clazz->getField<JNativeIosPermissionRequest>("ios");
      jni::local_ref<JNativeIosPermissionRequest> ios = this->getFieldValue(fieldIos);
      return NativePermissionRequest(
        ios != nullptr ? std::make_optional(ios->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<JNativePermissionRequest::javaobject> fromCpp(const NativePermissionRequest& value) {
      using JSignature = JNativePermissionRequest(jni::alias_ref<JNativeIosPermissionRequest>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.ios.has_value() ? JNativeIosPermissionRequest::fromCpp(value.ios.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
