///
/// JNativeLinearListLayoutConfig.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 "NativeLinearListLayoutConfig.hpp"

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

namespace margelo::nitro::reactnativelist {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeLinearListLayoutConfig by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeLinearListLayoutConfig toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldTopInset = clazz->getField<double>("topInset");
      double topInset = this->getFieldValue(fieldTopInset);
      static const auto fieldBottomInset = clazz->getField<double>("bottomInset");
      double bottomInset = this->getFieldValue(fieldBottomInset);
      static const auto fieldItemSpacing = clazz->getField<double>("itemSpacing");
      double itemSpacing = this->getFieldValue(fieldItemSpacing);
      static const auto fieldItemHorizontalInset = clazz->getField<double>("itemHorizontalInset");
      double itemHorizontalInset = this->getFieldValue(fieldItemHorizontalInset);
      static const auto fieldItemVerticalInset = clazz->getField<double>("itemVerticalInset");
      double itemVerticalInset = this->getFieldValue(fieldItemVerticalInset);
      static const auto fieldIosConfig = clazz->getField<JNativeLinearListLayoutIOSConfig>("iosConfig");
      jni::local_ref<JNativeLinearListLayoutIOSConfig> iosConfig = this->getFieldValue(fieldIosConfig);
      return NativeLinearListLayoutConfig(
        topInset,
        bottomInset,
        itemSpacing,
        itemHorizontalInset,
        itemVerticalInset,
        iosConfig != nullptr ? std::make_optional(iosConfig->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<JNativeLinearListLayoutConfig::javaobject> fromCpp(const NativeLinearListLayoutConfig& value) {
      using JSignature = JNativeLinearListLayoutConfig(double, double, double, double, double, jni::alias_ref<JNativeLinearListLayoutIOSConfig>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.topInset,
        value.bottomInset,
        value.itemSpacing,
        value.itemHorizontalInset,
        value.itemVerticalInset,
        value.iosConfig.has_value() ? JNativeLinearListLayoutIOSConfig::fromCpp(value.iosConfig.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::reactnativelist
