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

#include "JHybridNativeBleNitroFactorySpec.hpp"

// Forward declaration of `HybridNativeBleNitroSpec` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { class HybridNativeBleNitroSpec; }
// Forward declaration of `BLEDevice` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct BLEDevice; }
// Forward declaration of `ManufacturerData` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
// Forward declaration of `ManufacturerDataEntry` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
// Forward declaration of `ServiceData` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ServiceData; }
// Forward declaration of `ServiceDataEntry` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ServiceDataEntry; }

#include <memory>
#include "HybridNativeBleNitroSpec.hpp"
#include "JHybridNativeBleNitroSpec.hpp"
#include <string>
#include <optional>
#include "BLEDevice.hpp"
#include <vector>
#include <functional>
#include "JFunc_void_std__vector_BLEDevice_.hpp"
#include <NitroModules/JNICallable.hpp>
#include "JBLEDevice.hpp"
#include "ManufacturerData.hpp"
#include "JManufacturerData.hpp"
#include "ManufacturerDataEntry.hpp"
#include "JManufacturerDataEntry.hpp"
#include <NitroModules/ArrayBuffer.hpp>
#include <NitroModules/JArrayBuffer.hpp>
#include "ServiceData.hpp"
#include "JServiceData.hpp"
#include "ServiceDataEntry.hpp"
#include "JServiceDataEntry.hpp"

namespace margelo::nitro::co::zyke::ble {

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

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

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

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

  // Properties
  

  // Methods
  std::shared_ptr<HybridNativeBleNitroSpec> JHybridNativeBleNitroFactorySpec::create(const std::optional<std::string>& nativeRestoreStateIdentifier, const std::optional<std::function<void(const std::vector<BLEDevice>& /* peripherals */)>>& restoreStateCallback) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridNativeBleNitroSpec::JavaPart>(jni::alias_ref<jni::JString> /* nativeRestoreStateIdentifier */, jni::alias_ref<JFunc_void_std__vector_BLEDevice_::javaobject> /* restoreStateCallback */)>("create_cxx");
    auto __result = method(_javaPart, nativeRestoreStateIdentifier.has_value() ? jni::make_jstring(nativeRestoreStateIdentifier.value()) : nullptr, restoreStateCallback.has_value() ? JFunc_void_std__vector_BLEDevice__cxx::fromCpp(restoreStateCallback.value()) : nullptr);
    return __result->getJHybridNativeBleNitroSpec();
  }

} // namespace margelo::nitro::co::zyke::ble
