///
/// JFunc_void_SelectionActionEvent.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 <functional>

#include "SelectionActionEvent.hpp"
#include <functional>
#include <NitroModules/JNICallable.hpp>
#include "JSelectionActionEvent.hpp"
#include "Locator.hpp"
#include "JLocator.hpp"
#include <string>
#include <optional>
#include "LocatorLocations.hpp"
#include "JLocatorLocations.hpp"
#include "LocatorText.hpp"
#include "JLocatorText.hpp"

namespace margelo::nitro::readium {

  using namespace facebook;

  /**
   * Represents the Java/Kotlin callback `(event: SelectionActionEvent) -> Unit`.
   * This can be passed around between C++ and Java/Kotlin.
   */
  struct JFunc_void_SelectionActionEvent: public jni::JavaClass<JFunc_void_SelectionActionEvent> {
  public:
    static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativereadium/Func_void_SelectionActionEvent;";

  public:
    /**
     * Invokes the function this `JFunc_void_SelectionActionEvent` instance holds through JNI.
     */
    void invoke(const SelectionActionEvent& event) const {
      static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSelectionActionEvent> /* event */)>("invoke");
      method(self(), JSelectionActionEvent::fromCpp(event));
    }
  };

  /**
   * An implementation of Func_void_SelectionActionEvent that is backed by a C++ implementation (using `std::function<...>`)
   */
  class JFunc_void_SelectionActionEvent_cxx final: public jni::HybridClass<JFunc_void_SelectionActionEvent_cxx, JFunc_void_SelectionActionEvent> {
  public:
    static jni::local_ref<JFunc_void_SelectionActionEvent::javaobject> fromCpp(const std::function<void(const SelectionActionEvent& /* event */)>& func) {
      return JFunc_void_SelectionActionEvent_cxx::newObjectCxxArgs(func);
    }

  public:
    /**
     * Invokes the C++ `std::function<...>` this `JFunc_void_SelectionActionEvent_cxx` instance holds.
     */
    void invoke_cxx(jni::alias_ref<JSelectionActionEvent> event) {
      _func(event->toCpp());
    }

  public:
    [[nodiscard]]
    inline const std::function<void(const SelectionActionEvent& /* event */)>& getFunction() const {
      return _func;
    }

  public:
    static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativereadium/Func_void_SelectionActionEvent_cxx;";
    static void registerNatives() {
      registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_SelectionActionEvent_cxx::invoke_cxx)});
    }

  private:
    explicit JFunc_void_SelectionActionEvent_cxx(const std::function<void(const SelectionActionEvent& /* event */)>& func): _func(func) { }

  private:
    friend HybridBase;
    std::function<void(const SelectionActionEvent& /* event */)> _func;
  };

} // namespace margelo::nitro::readium
