///
/// JTextStyle.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 "TextStyle.hpp"

#include "FontWeight.hpp"
#include "JFontWeight.hpp"
#include "JTextAlign.hpp"
#include "JTextShadow.hpp"
#include "TextAlign.hpp"
#include "TextShadow.hpp"
#include <optional>
#include <string>

namespace margelo::nitro::videopipeline {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct TextStyle by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    TextStyle toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldFontFamily = clazz->getField<jni::JString>("fontFamily");
      jni::local_ref<jni::JString> fontFamily = this->getFieldValue(fieldFontFamily);
      static const auto fieldFontSize = clazz->getField<double>("fontSize");
      double fontSize = this->getFieldValue(fieldFontSize);
      static const auto fieldColor = clazz->getField<jni::JString>("color");
      jni::local_ref<jni::JString> color = this->getFieldValue(fieldColor);
      static const auto fieldWeight = clazz->getField<JFontWeight>("weight");
      jni::local_ref<JFontWeight> weight = this->getFieldValue(fieldWeight);
      static const auto fieldAlign = clazz->getField<JTextAlign>("align");
      jni::local_ref<JTextAlign> align = this->getFieldValue(fieldAlign);
      static const auto fieldShadow = clazz->getField<JTextShadow>("shadow");
      jni::local_ref<JTextShadow> shadow = this->getFieldValue(fieldShadow);
      return TextStyle(
        fontFamily != nullptr ? std::make_optional(fontFamily->toStdString()) : std::nullopt,
        fontSize,
        color->toStdString(),
        weight != nullptr ? std::make_optional(weight->toCpp()) : std::nullopt,
        align != nullptr ? std::make_optional(align->toCpp()) : std::nullopt,
        shadow != nullptr ? std::make_optional(shadow->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<JTextStyle::javaobject> fromCpp(const TextStyle& value) {
      using JSignature = JTextStyle(jni::alias_ref<jni::JString>, double, jni::alias_ref<jni::JString>, jni::alias_ref<JFontWeight>, jni::alias_ref<JTextAlign>, jni::alias_ref<JTextShadow>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.fontFamily.has_value() ? jni::make_jstring(value.fontFamily.value()) : nullptr,
        value.fontSize,
        jni::make_jstring(value.color),
        value.weight.has_value() ? JFontWeight::fromCpp(value.weight.value()) : nullptr,
        value.align.has_value() ? JTextAlign::fromCpp(value.align.value()) : nullptr,
        value.shadow.has_value() ? JTextShadow::fromCpp(value.shadow.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::videopipeline
