///
/// JSaveRecordResult.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 "SaveRecordResult.hpp"

#include <string>

namespace margelo::nitro::cloudkitmodule {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct SaveRecordResult by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    SaveRecordResult toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldRecordID = clazz->getField<jni::JString>("recordID");
      jni::local_ref<jni::JString> recordID = this->getFieldValue(fieldRecordID);
      static const auto fieldCreatedAt = clazz->getField<double>("createdAt");
      double createdAt = this->getFieldValue(fieldCreatedAt);
      return SaveRecordResult(
        recordID->toStdString(),
        createdAt
      );
    }

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

} // namespace margelo::nitro::cloudkitmodule
