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

#pragma once

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

#include "ColorScheme.hpp"
#include "JColorScheme.hpp"
#include "JScreenDimensions.hpp"
#include "JScreenInsets.hpp"
#include "JScreenOrientation.hpp"
#include "ScreenDimensions.hpp"
#include "ScreenInsets.hpp"
#include "ScreenOrientation.hpp"
#include <string>

namespace margelo::nitro::stylesheet {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct DeviceTraits by copying all values to C++.
     */
    [[maybe_unused]]
    DeviceTraits toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldColorScheme = clazz->getField<JColorScheme>("colorScheme");
      jni::local_ref<JColorScheme> colorScheme = this->getFieldValue(fieldColorScheme);
      static const auto fieldScreenDimensions = clazz->getField<JScreenDimensions>("screenDimensions");
      jni::local_ref<JScreenDimensions> screenDimensions = this->getFieldValue(fieldScreenDimensions);
      static const auto fieldContentSizeCategory = clazz->getField<jni::JString>("contentSizeCategory");
      jni::local_ref<jni::JString> contentSizeCategory = this->getFieldValue(fieldContentSizeCategory);
      static const auto fieldScreenInsets = clazz->getField<JScreenInsets>("screenInsets");
      jni::local_ref<JScreenInsets> screenInsets = this->getFieldValue(fieldScreenInsets);
      static const auto fieldDisplayScale = clazz->getField<double>("displayScale");
      double displayScale = this->getFieldValue(fieldDisplayScale);
      static const auto fieldFontScale = clazz->getField<double>("fontScale");
      double fontScale = this->getFieldValue(fieldFontScale);
      static const auto fieldIsRTL = clazz->getField<jboolean>("isRTL");
      jboolean isRTL = this->getFieldValue(fieldIsRTL);
      static const auto fieldScreenOrientation = clazz->getField<JScreenOrientation>("screenOrientation");
      jni::local_ref<JScreenOrientation> screenOrientation = this->getFieldValue(fieldScreenOrientation);
      static const auto fieldPixelRatio = clazz->getField<double>("pixelRatio");
      double pixelRatio = this->getFieldValue(fieldPixelRatio);
      return DeviceTraits(
        colorScheme->toCpp(),
        screenDimensions->toCpp(),
        contentSizeCategory->toStdString(),
        screenInsets->toCpp(),
        displayScale,
        fontScale,
        static_cast<bool>(isRTL),
        screenOrientation->toCpp(),
        pixelRatio
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JDeviceTraits::javaobject> fromCpp(const DeviceTraits& value) {
      return newInstance(
        JColorScheme::fromCpp(value.colorScheme),
        JScreenDimensions::fromCpp(value.screenDimensions),
        jni::make_jstring(value.contentSizeCategory),
        JScreenInsets::fromCpp(value.screenInsets),
        value.displayScale,
        value.fontScale,
        value.isRTL,
        JScreenOrientation::fromCpp(value.screenOrientation),
        value.pixelRatio
      );
    }
  };

} // namespace margelo::nitro::stylesheet
