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

#pragma once

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

#include <optional>

namespace margelo::nitro::reactnativelist {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeItemSizeEstimate by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeItemSizeEstimate toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldWidth = clazz->getField<jni::JDouble>("width");
      jni::local_ref<jni::JDouble> width = this->getFieldValue(fieldWidth);
      static const auto fieldHeight = clazz->getField<jni::JDouble>("height");
      jni::local_ref<jni::JDouble> height = this->getFieldValue(fieldHeight);
      return NativeItemSizeEstimate(
        width != nullptr ? std::make_optional(width->value()) : std::nullopt,
        height != nullptr ? std::make_optional(height->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<JNativeItemSizeEstimate::javaobject> fromCpp(const NativeItemSizeEstimate& value) {
      using JSignature = JNativeItemSizeEstimate(jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.width.has_value() ? jni::JDouble::valueOf(value.width.value()) : nullptr,
        value.height.has_value() ? jni::JDouble::valueOf(value.height.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::reactnativelist
