///
/// JMailErrorStruct.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 "MailErrorStruct.hpp"

#include <string>

namespace margelo::nitro::mailengine {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct MailErrorStruct by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    MailErrorStruct 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);
      return MailErrorStruct(
        code->toStdString(),
        message->toStdString()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JMailErrorStruct::javaobject> fromCpp(const MailErrorStruct& value) {
      using JSignature = JMailErrorStruct(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.code),
        jni::make_jstring(value.message)
      );
    }
  };

} // namespace margelo::nitro::mailengine
