///
/// JCropRatio.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 "CropRatio.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::multipleimagepicker {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct CropRatio by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    CropRatio toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldTitle = clazz->getField<jni::JString>("title");
      jni::local_ref<jni::JString> title = this->getFieldValue(fieldTitle);
      static const auto fieldWidth = clazz->getField<double>("width");
      double width = this->getFieldValue(fieldWidth);
      static const auto fieldHeight = clazz->getField<double>("height");
      double height = this->getFieldValue(fieldHeight);
      return CropRatio(
        title != nullptr ? std::make_optional(title->toStdString()) : std::nullopt,
        width,
        height
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JCropRatio::javaobject> fromCpp(const CropRatio& value) {
      return newInstance(
        value.title.has_value() ? jni::make_jstring(value.title.value()) : nullptr,
        value.width,
        value.height
      );
    }
  };

} // namespace margelo::nitro::multipleimagepicker
