///
/// JShareItem.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 "ShareItem.hpp"

#include "JShareItemType.hpp"
#include "ShareItemType.hpp"
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct ShareItem by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    ShareItem toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldType = clazz->getField<JShareItemType>("type");
      jni::local_ref<JShareItemType> type = this->getFieldValue(fieldType);
      static const auto fieldValue = clazz->getField<jni::JString>("value");
      jni::local_ref<jni::JString> value = this->getFieldValue(fieldValue);
      return ShareItem(
        type->toCpp(),
        value->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<JShareItem::javaobject> fromCpp(const ShareItem& value) {
      using JSignature = JShareItem(jni::alias_ref<JShareItemType>, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JShareItemType::fromCpp(value.type),
        jni::make_jstring(value.value)
      );
    }
  };

} // namespace margelo::nitro::one
