///
/// JFunc_void_LDP_Range.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 "LDP_Range.hpp"
#include <functional>
#include <NitroModules/JNICallable.hpp>
#include "JLDP_Range.hpp"
#include <string>
#include <optional>

namespace margelo::nitro::lunardatepicker {

  using namespace facebook;

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

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

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

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

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

  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/lunardatepicker/Func_void_LDP_Range_cxx;";
    static void registerNatives() {
      registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_LDP_Range_cxx::invoke_cxx)});
    }

  private:
    explicit JFunc_void_LDP_Range_cxx(const std::function<void(const LDP_Range& /* result */)>& func): _func(func) { }

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

} // namespace margelo::nitro::lunardatepicker
