///
/// JNativeAzureError.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 "NativeAzureError.hpp"

#include <string>

namespace margelo::nitro::clarion::azure {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeAzureError by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeAzureError toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldCode = clazz->getField<jni::JString>("code");
      jni::local_ref<jni::JString> code = this->getFieldValue(fieldCode);
      static const auto fieldMessage = clazz->getField<jni::JString>("message");
      jni::local_ref<jni::JString> message = this->getFieldValue(fieldMessage);
      static const auto fieldRecoverable = clazz->getField<jboolean>("recoverable");
      jboolean recoverable = this->getFieldValue(fieldRecoverable);
      return NativeAzureError(
        code->toStdString(),
        message->toStdString(),
        static_cast<bool>(recoverable)
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JNativeAzureError::javaobject> fromCpp(const NativeAzureError& value) {
      using JSignature = JNativeAzureError(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jboolean);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.code),
        jni::make_jstring(value.message),
        value.recoverable
      );
    }
  };

} // namespace margelo::nitro::clarion::azure
