///
/// JLDP_Range.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_Range.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::lunardatepicker {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct LDP_Range by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    LDP_Range toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldFrom = clazz->getField<jni::JString>("from");
      jni::local_ref<jni::JString> from = this->getFieldValue(fieldFrom);
      static const auto fieldTo = clazz->getField<jni::JString>("to");
      jni::local_ref<jni::JString> to = this->getFieldValue(fieldTo);
      return LDP_Range(
        from->toStdString(),
        to != nullptr ? std::make_optional(to->toStdString()) : 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_Range::javaobject> fromCpp(const LDP_Range& value) {
      return newInstance(
        jni::make_jstring(value.from),
        value.to.has_value() ? jni::make_jstring(value.to.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::lunardatepicker
