///
/// JAccountInfoResult.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 "AccountInfoResult.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::cloudkitmodule {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct AccountInfoResult by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    AccountInfoResult toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldStatus = clazz->getField<double>("status");
      double status = this->getFieldValue(fieldStatus);
      static const auto fieldStatusName = clazz->getField<jni::JString>("statusName");
      jni::local_ref<jni::JString> statusName = this->getFieldValue(fieldStatusName);
      static const auto fieldContainerUserId = clazz->getField<jni::JString>("containerUserId");
      jni::local_ref<jni::JString> containerUserId = this->getFieldValue(fieldContainerUserId);
      return AccountInfoResult(
        status,
        statusName->toStdString(),
        containerUserId != nullptr ? std::make_optional(containerUserId->toStdString()) : 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<JAccountInfoResult::javaobject> fromCpp(const AccountInfoResult& value) {
      using JSignature = JAccountInfoResult(double, 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,
        value.status,
        jni::make_jstring(value.statusName),
        value.containerUserId.has_value() ? jni::make_jstring(value.containerUserId.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::cloudkitmodule
