///
/// JDecorationStyle.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 "DecorationStyle.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::readium {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct DecorationStyle by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    DecorationStyle toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldType = clazz->getField<jni::JString>("type");
      jni::local_ref<jni::JString> type = this->getFieldValue(fieldType);
      static const auto fieldTint = clazz->getField<jni::JString>("tint");
      jni::local_ref<jni::JString> tint = this->getFieldValue(fieldTint);
      static const auto fieldIsActive = clazz->getField<jni::JBoolean>("isActive");
      jni::local_ref<jni::JBoolean> isActive = this->getFieldValue(fieldIsActive);
      static const auto fieldId = clazz->getField<jni::JString>("id");
      jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
      static const auto fieldHtml = clazz->getField<jni::JString>("html");
      jni::local_ref<jni::JString> html = this->getFieldValue(fieldHtml);
      static const auto fieldCss = clazz->getField<jni::JString>("css");
      jni::local_ref<jni::JString> css = this->getFieldValue(fieldCss);
      static const auto fieldLayout = clazz->getField<jni::JString>("layout");
      jni::local_ref<jni::JString> layout = this->getFieldValue(fieldLayout);
      static const auto fieldWidth = clazz->getField<jni::JString>("width");
      jni::local_ref<jni::JString> width = this->getFieldValue(fieldWidth);
      return DecorationStyle(
        type->toStdString(),
        tint != nullptr ? std::make_optional(tint->toStdString()) : std::nullopt,
        isActive != nullptr ? std::make_optional(static_cast<bool>(isActive->value())) : std::nullopt,
        id != nullptr ? std::make_optional(id->toStdString()) : std::nullopt,
        html != nullptr ? std::make_optional(html->toStdString()) : std::nullopt,
        css != nullptr ? std::make_optional(css->toStdString()) : std::nullopt,
        layout != nullptr ? std::make_optional(layout->toStdString()) : std::nullopt,
        width != nullptr ? std::make_optional(width->toStdString()) : 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<JDecorationStyle::javaobject> fromCpp(const DecorationStyle& value) {
      using JSignature = JDecorationStyle(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.type),
        value.tint.has_value() ? jni::make_jstring(value.tint.value()) : nullptr,
        value.isActive.has_value() ? jni::JBoolean::valueOf(value.isActive.value()) : nullptr,
        value.id.has_value() ? jni::make_jstring(value.id.value()) : nullptr,
        value.html.has_value() ? jni::make_jstring(value.html.value()) : nullptr,
        value.css.has_value() ? jni::make_jstring(value.css.value()) : nullptr,
        value.layout.has_value() ? jni::make_jstring(value.layout.value()) : nullptr,
        value.width.has_value() ? jni::make_jstring(value.width.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::readium
