///
/// JShareResult.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 "ShareResult.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct ShareResult by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    ShareResult toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldCompleted = clazz->getField<jboolean>("completed");
      jboolean completed = this->getFieldValue(fieldCompleted);
      static const auto fieldActivityType = clazz->getField<jni::JString>("activityType");
      jni::local_ref<jni::JString> activityType = this->getFieldValue(fieldActivityType);
      return ShareResult(
        static_cast<bool>(completed),
        activityType != nullptr ? std::make_optional(activityType->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<JShareResult::javaobject> fromCpp(const ShareResult& value) {
      using JSignature = JShareResult(jboolean, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.completed,
        value.activityType.has_value() ? jni::make_jstring(value.activityType.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
