///
/// JNativeLinearListLayoutIOSConfig.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 "NativeLinearListLayoutIOSConfig.hpp"

#include "JNativeItemSizeEstimate.hpp"
#include "NativeItemSizeEstimate.hpp"
#include <optional>

namespace margelo::nitro::reactnativelist {

  using namespace facebook;

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

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

} // namespace margelo::nitro::reactnativelist
