///
/// JLDP_PriceData.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_PriceData.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::lunardatepicker {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct LDP_PriceData by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    LDP_PriceData toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldDate = clazz->getField<jni::JString>("date");
      jni::local_ref<jni::JString> date = this->getFieldValue(fieldDate);
      static const auto fieldPrice = clazz->getField<double>("price");
      double price = this->getFieldValue(fieldPrice);
      static const auto fieldIsCheapest = clazz->getField<jni::JBoolean>("isCheapest");
      jni::local_ref<jni::JBoolean> isCheapest = this->getFieldValue(fieldIsCheapest);
      return LDP_PriceData(
        date->toStdString(),
        price,
        isCheapest != nullptr ? std::make_optional(static_cast<bool>(isCheapest->value())) : std::nullopt
      );
    }

  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_PriceData::javaobject> fromCpp(const LDP_PriceData& value) {
      return newInstance(
        jni::make_jstring(value.date),
        value.price,
        value.isCheapest.has_value() ? jni::JBoolean::valueOf(value.isCheapest.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::lunardatepicker
