///
/// JFunc_void_UrlResponseInfo_std__string.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 "UrlResponseInfo.hpp"
#include <string>
#include <functional>
#include <NitroModules/JNICallable.hpp>
#include "JUrlResponseInfo.hpp"
#include <unordered_map>
#include "HttpHeader.hpp"
#include <vector>
#include "JHttpHeader.hpp"

namespace margelo::nitro::nitrofetch {

  using namespace facebook;

  /**
   * Represents the Java/Kotlin callback `(info: UrlResponseInfo, newLocationUrl: String) -> Unit`.
   * This can be passed around between C++ and Java/Kotlin.
   */
  struct JFunc_void_UrlResponseInfo_std__string: public jni::JavaClass<JFunc_void_UrlResponseInfo_std__string> {
  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrofetch/Func_void_UrlResponseInfo_std__string;";

  public:
    /**
     * Invokes the function this `JFunc_void_UrlResponseInfo_std__string` instance holds through JNI.
     */
    void invoke(const UrlResponseInfo& info, const std::string& newLocationUrl) const {
      static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JUrlResponseInfo> /* info */, jni::alias_ref<jni::JString> /* newLocationUrl */)>("invoke");
      method(self(), JUrlResponseInfo::fromCpp(info), jni::make_jstring(newLocationUrl));
    }
  };

  /**
   * An implementation of Func_void_UrlResponseInfo_std__string that is backed by a C++ implementation (using `std::function<...>`)
   */
  class JFunc_void_UrlResponseInfo_std__string_cxx final: public jni::HybridClass<JFunc_void_UrlResponseInfo_std__string_cxx, JFunc_void_UrlResponseInfo_std__string> {
  public:
    static jni::local_ref<JFunc_void_UrlResponseInfo_std__string::javaobject> fromCpp(const std::function<void(const UrlResponseInfo& /* info */, const std::string& /* newLocationUrl */)>& func) {
      return JFunc_void_UrlResponseInfo_std__string_cxx::newObjectCxxArgs(func);
    }

  public:
    /**
     * Invokes the C++ `std::function<...>` this `JFunc_void_UrlResponseInfo_std__string_cxx` instance holds.
     */
    void invoke_cxx(jni::alias_ref<JUrlResponseInfo> info, jni::alias_ref<jni::JString> newLocationUrl) {
      _func(info->toCpp(), newLocationUrl->toStdString());
    }

  public:
    [[nodiscard]]
    inline const std::function<void(const UrlResponseInfo& /* info */, const std::string& /* newLocationUrl */)>& getFunction() const {
      return _func;
    }

  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrofetch/Func_void_UrlResponseInfo_std__string_cxx;";
    static void registerNatives() {
      registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_UrlResponseInfo_std__string_cxx::invoke_cxx)});
    }

  private:
    explicit JFunc_void_UrlResponseInfo_std__string_cxx(const std::function<void(const UrlResponseInfo& /* info */, const std::string& /* newLocationUrl */)>& func): _func(func) { }

  private:
    friend HybridBase;
    std::function<void(const UrlResponseInfo& /* info */, const std::string& /* newLocationUrl */)> _func;
  };

} // namespace margelo::nitro::nitrofetch
