///
/// JHybridNitroFetchSpec.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#include "JHybridNitroFetchSpec.hpp"

// Forward declaration of `HybridNitroFetchClientSpec` to properly resolve imports.
namespace margelo::nitro::nitrofetch { class HybridNitroFetchClientSpec; }

#include <memory>
#include "HybridNitroFetchClientSpec.hpp"
#include "JHybridNitroFetchClientSpec.hpp"

namespace margelo::nitro::nitrofetch {

  std::shared_ptr<JHybridNitroFetchSpec> JHybridNitroFetchSpec::JavaPart::getJHybridNitroFetchSpec() {
    auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
    auto castHybridObject = std::dynamic_pointer_cast<JHybridNitroFetchSpec>(hybridObject);
    if (castHybridObject == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to downcast JHybridObject to JHybridNitroFetchSpec!");
    }
    return castHybridObject;
  }

  jni::local_ref<JHybridNitroFetchSpec::CxxPart::jhybriddata> JHybridNitroFetchSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
    return makeCxxInstance(jThis);
  }

  std::shared_ptr<JHybridObject> JHybridNitroFetchSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
    auto castJavaPart = jni::dynamic_ref_cast<JHybridNitroFetchSpec::JavaPart>(javaPart);
    if (castJavaPart == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridNitroFetchSpec::JavaPart!");
    }
    return std::make_shared<JHybridNitroFetchSpec>(castJavaPart);
  }

  void JHybridNitroFetchSpec::CxxPart::registerNatives() {
    registerHybrid({
      makeNativeMethod("initHybrid", JHybridNitroFetchSpec::CxxPart::initHybrid),
    });
  }

  // Properties
  

  // Methods
  std::shared_ptr<HybridNitroFetchClientSpec> JHybridNitroFetchSpec::createClient() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridNitroFetchClientSpec::JavaPart>()>("createClient");
    auto __result = method(_javaPart);
    return __result->getJHybridNitroFetchClientSpec();
  }

} // namespace margelo::nitro::nitrofetch
