///
/// JFunc_void_LocationRegion.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 "LocationRegion.hpp"
#include <functional>
#include <NitroModules/JNICallable.hpp>
#include "JLocationRegion.hpp"
#include <string>
#include "RegionCenter.hpp"
#include "JRegionCenter.hpp"
#include <optional>
#include "RegionState.hpp"
#include "JRegionState.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

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

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

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

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

  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/one/Func_void_LocationRegion_cxx;";
    static void registerNatives() {
      registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_LocationRegion_cxx::invoke_cxx)});
    }

  private:
    explicit JFunc_void_LocationRegion_cxx(const std::function<void(const LocationRegion& /* region */)>& func): _func(func) { }

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

} // namespace margelo::nitro::one
