///
/// JSelectionActionEvent.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 "SelectionActionEvent.hpp"

#include "JLocator.hpp"
#include "JLocatorLocations.hpp"
#include "JLocatorText.hpp"
#include "Locator.hpp"
#include "LocatorLocations.hpp"
#include "LocatorText.hpp"
#include <optional>
#include <string>

namespace margelo::nitro::readium {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct SelectionActionEvent by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    SelectionActionEvent toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldLocator = clazz->getField<JLocator>("locator");
      jni::local_ref<JLocator> locator = this->getFieldValue(fieldLocator);
      static const auto fieldSelectedText = clazz->getField<jni::JString>("selectedText");
      jni::local_ref<jni::JString> selectedText = this->getFieldValue(fieldSelectedText);
      static const auto fieldActionId = clazz->getField<jni::JString>("actionId");
      jni::local_ref<jni::JString> actionId = this->getFieldValue(fieldActionId);
      return SelectionActionEvent(
        locator->toCpp(),
        selectedText->toStdString(),
        actionId->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<JSelectionActionEvent::javaobject> fromCpp(const SelectionActionEvent& value) {
      using JSignature = JSelectionActionEvent(jni::alias_ref<JLocator>, 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,
        JLocator::fromCpp(value.locator),
        jni::make_jstring(value.selectedText),
        jni::make_jstring(value.actionId)
      );
    }
  };

} // namespace margelo::nitro::readium
