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

#include "JHybridUiListViewSpec.hpp"

// Forward declaration of `HybridUiListModuleSpec` to properly resolve imports.
namespace margelo::nitro::reactnativelist { class HybridUiListModuleSpec; }
// Forward declaration of `NativeListItem` to properly resolve imports.
namespace margelo::nitro::reactnativelist { struct NativeListItem; }
// Forward declaration of `HybridNativeListDataSourceSpec` to properly resolve imports.
namespace margelo::nitro::reactnativelist { class HybridNativeListDataSourceSpec; }
// Forward declaration of `HybridNativeListLayoutSpec` to properly resolve imports.
namespace margelo::nitro::reactnativelist { class HybridNativeListLayoutSpec; }

#include <memory>
#include "HybridUiListModuleSpec.hpp"
#include "JHybridUiListModuleSpec.hpp"
#include <string>
#include <functional>
#include "JFunc_double_std__string_double.hpp"
#include <NitroModules/JNICallable.hpp>
#include "NativeListItem.hpp"
#include "JFunc_bool_double_NativeListItem_double.hpp"
#include "JNativeListItem.hpp"
#include <optional>
#include <NitroModules/AnyMap.hpp>
#include <NitroModules/JAnyMap.hpp>
#include "JFunc_bool_double.hpp"
#include "HybridNativeListDataSourceSpec.hpp"
#include "JHybridNativeListDataSourceSpec.hpp"
#include "HybridNativeListLayoutSpec.hpp"
#include "JHybridNativeListLayoutSpec.hpp"

namespace margelo::nitro::reactnativelist {

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

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

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

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

  // Properties
  

  // Methods
  void JHybridUiListViewSpec::setListCallbacks(const std::shared_ptr<HybridUiListModuleSpec>& uiListModule, const std::function<double(const std::string& /* type */, double /* surfaceId */)>& createView, const std::function<bool(double /* reactTag */, const NativeListItem& /* item */, double /* index */)>& updateView, const std::function<bool(double /* surfaceId */)>& disposeView) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JHybridUiListModuleSpec::JavaPart> /* uiListModule */, jni::alias_ref<JFunc_double_std__string_double::javaobject> /* createView */, jni::alias_ref<JFunc_bool_double_NativeListItem_double::javaobject> /* updateView */, jni::alias_ref<JFunc_bool_double::javaobject> /* disposeView */)>("setListCallbacks_cxx");
    method(_javaPart, std::dynamic_pointer_cast<JHybridUiListModuleSpec>(uiListModule)->getJavaPart(), JFunc_double_std__string_double_cxx::fromCpp(createView), JFunc_bool_double_NativeListItem_double_cxx::fromCpp(updateView), JFunc_bool_double_cxx::fromCpp(disposeView));
  }
  void JHybridUiListViewSpec::setDataSource(const std::shared_ptr<HybridNativeListDataSourceSpec>& dataSource) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JHybridNativeListDataSourceSpec::JavaPart> /* dataSource */)>("setDataSource");
    method(_javaPart, std::dynamic_pointer_cast<JHybridNativeListDataSourceSpec>(dataSource)->getJavaPart());
  }
  void JHybridUiListViewSpec::setLayout(const std::shared_ptr<HybridNativeListLayoutSpec>& layout) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JHybridNativeListLayoutSpec::JavaPart> /* layout */)>("setLayout");
    method(_javaPart, std::dynamic_pointer_cast<JHybridNativeListLayoutSpec>(layout)->getJavaPart());
  }
  void JHybridUiListViewSpec::disposeRendererSurface() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("disposeRendererSurface");
    method(_javaPart);
  }

} // namespace margelo::nitro::reactnativelist
