///
/// JFunc_bool_NativeListItem_NativeListItem.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 "NativeListItem.hpp"
#include <functional>
#include <NitroModules/JNICallable.hpp>
#include "JNativeListItem.hpp"
#include <string>
#include <optional>
#include <NitroModules/AnyMap.hpp>
#include <NitroModules/JAnyMap.hpp>

namespace margelo::nitro::reactnativelist {

  using namespace facebook;

  /**
   * Represents the Java/Kotlin callback `(oldItem: NativeListItem, newItem: NativeListItem) -> Boolean`.
   * This can be passed around between C++ and Java/Kotlin.
   */
  struct JFunc_bool_NativeListItem_NativeListItem: public jni::JavaClass<JFunc_bool_NativeListItem_NativeListItem> {
  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativelist/Func_bool_NativeListItem_NativeListItem;";

  public:
    /**
     * Invokes the function this `JFunc_bool_NativeListItem_NativeListItem` instance holds through JNI.
     */
    bool invoke(const NativeListItem& oldItem, const NativeListItem& newItem) const {
      static const auto method = javaClassStatic()->getMethod<jboolean(jni::alias_ref<JNativeListItem> /* oldItem */, jni::alias_ref<JNativeListItem> /* newItem */)>("invoke");
      auto __result = method(self(), JNativeListItem::fromCpp(oldItem), JNativeListItem::fromCpp(newItem));
      return static_cast<bool>(__result);
    }
  };

  /**
   * An implementation of Func_bool_NativeListItem_NativeListItem that is backed by a C++ implementation (using `std::function<...>`)
   */
  class JFunc_bool_NativeListItem_NativeListItem_cxx final: public jni::HybridClass<JFunc_bool_NativeListItem_NativeListItem_cxx, JFunc_bool_NativeListItem_NativeListItem> {
  public:
    static jni::local_ref<JFunc_bool_NativeListItem_NativeListItem::javaobject> fromCpp(const std::function<bool(const NativeListItem& /* oldItem */, const NativeListItem& /* newItem */)>& func) {
      return JFunc_bool_NativeListItem_NativeListItem_cxx::newObjectCxxArgs(func);
    }

  public:
    /**
     * Invokes the C++ `std::function<...>` this `JFunc_bool_NativeListItem_NativeListItem_cxx` instance holds.
     */
    jboolean invoke_cxx(jni::alias_ref<JNativeListItem> oldItem, jni::alias_ref<JNativeListItem> newItem) {
      bool __result = _func(oldItem->toCpp(), newItem->toCpp());
      return __result;
    }

  public:
    [[nodiscard]]
    inline const std::function<bool(const NativeListItem& /* oldItem */, const NativeListItem& /* newItem */)>& getFunction() const {
      return _func;
    }

  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/reactnativelist/Func_bool_NativeListItem_NativeListItem_cxx;";
    static void registerNatives() {
      registerHybrid({makeNativeMethod("invoke_cxx", JFunc_bool_NativeListItem_NativeListItem_cxx::invoke_cxx)});
    }

  private:
    explicit JFunc_bool_NativeListItem_NativeListItem_cxx(const std::function<bool(const NativeListItem& /* oldItem */, const NativeListItem& /* newItem */)>& func): _func(func) { }

  private:
    friend HybridBase;
    std::function<bool(const NativeListItem& /* oldItem */, const NativeListItem& /* newItem */)> _func;
  };

} // namespace margelo::nitro::reactnativelist
