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

#pragma once

#include <fbjni/fbjni.h>
#include "LDP_PriceUpdateParams.hpp"

#include "JLDP_PriceData.hpp"
#include "LDP_PriceData.hpp"
#include <optional>
#include <string>
#include <vector>

namespace margelo::nitro::lunardatepicker {

  using namespace facebook;

  /**
   * The C++ JNI bridge between the C++ struct "LDP_PriceUpdateParams" and the the Kotlin data class "LDP_PriceUpdateParams".
   */
  struct JLDP_PriceUpdateParams final: public jni::JavaClass<JLDP_PriceUpdateParams> {
  public:
    static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/lunardatepicker/LDP_PriceUpdateParams;";

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct LDP_PriceUpdateParams by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    LDP_PriceUpdateParams toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldMonth = clazz->getField<jni::JString>("month");
      jni::local_ref<jni::JString> month = this->getFieldValue(fieldMonth);
      static const auto fieldPrices = clazz->getField<jni::JArrayClass<JLDP_PriceData>>("prices");
      jni::local_ref<jni::JArrayClass<JLDP_PriceData>> prices = this->getFieldValue(fieldPrices);
      return LDP_PriceUpdateParams(
        month->toStdString(),
        [&]() {
          size_t __size = prices->size();
          std::vector<LDP_PriceData> __vector;
          __vector.reserve(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            auto __element = prices->getElement(__i);
            __vector.push_back(__element->toCpp());
          }
          return __vector;
        }()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JLDP_PriceUpdateParams::javaobject> fromCpp(const LDP_PriceUpdateParams& value) {
      return newInstance(
        jni::make_jstring(value.month),
        [&]() {
          size_t __size = value.prices.size();
          jni::local_ref<jni::JArrayClass<JLDP_PriceData>> __array = jni::JArrayClass<JLDP_PriceData>::newArray(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            const auto& __element = value.prices[__i];
            __array->setElement(__i, *JLDP_PriceData::fromCpp(__element));
          }
          return __array;
        }()
      );
    }
  };

} // namespace margelo::nitro::lunardatepicker
