///
/// JFunc_bool_double.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 <functional>
#include <NitroModules/JNICallable.hpp>

namespace margelo::nitro::reactnativelist {

  using namespace facebook;

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

  public:
    /**
     * Invokes the function this `JFunc_bool_double` instance holds through JNI.
     */
    bool invoke(double surfaceId) const {
      static const auto method = javaClassStatic()->getMethod<jboolean(double /* surfaceId */)>("invoke");
      auto __result = method(self(), surfaceId);
      return static_cast<bool>(__result);
    }
  };

  /**
   * An implementation of Func_bool_double that is backed by a C++ implementation (using `std::function<...>`)
   */
  class JFunc_bool_double_cxx final: public jni::HybridClass<JFunc_bool_double_cxx, JFunc_bool_double> {
  public:
    static jni::local_ref<JFunc_bool_double::javaobject> fromCpp(const std::function<bool(double /* surfaceId */)>& func) {
      return JFunc_bool_double_cxx::newObjectCxxArgs(func);
    }

  public:
    /**
     * Invokes the C++ `std::function<...>` this `JFunc_bool_double_cxx` instance holds.
     */
    jboolean invoke_cxx(double surfaceId) {
      bool __result = _func(surfaceId);
      return __result;
    }

  public:
    [[nodiscard]]
    inline const std::function<bool(double /* surfaceId */)>& getFunction() const {
      return _func;
    }

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

  private:
    explicit JFunc_bool_double_cxx(const std::function<bool(double /* surfaceId */)>& func): _func(func) { }

  private:
    friend HybridBase;
    std::function<bool(double /* surfaceId */)> _func;
  };

} // namespace margelo::nitro::reactnativelist
