///
/// JPAM_ToastParams.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 "PAM_ToastParams.hpp"

#include "JPAM_NativeAssetSource.hpp"
#include "PAM_NativeAssetSource.hpp"
#include <optional>
#include <string>

namespace margelo::nitro::progressandmodal {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct PAM_ToastParams by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    PAM_ToastParams toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldMessage = clazz->getField<jni::JString>("message");
      jni::local_ref<jni::JString> message = this->getFieldValue(fieldMessage);
      static const auto fieldBackgroundColor = clazz->getField<jni::JString>("backgroundColor");
      jni::local_ref<jni::JString> backgroundColor = this->getFieldValue(fieldBackgroundColor);
      static const auto fieldTextColor = clazz->getField<jni::JString>("textColor");
      jni::local_ref<jni::JString> textColor = this->getFieldValue(fieldTextColor);
      static const auto fieldFontSize = clazz->getField<jni::JDouble>("fontSize");
      jni::local_ref<jni::JDouble> fontSize = this->getFieldValue(fieldFontSize);
      static const auto fieldImage = clazz->getField<JPAM_NativeAssetSource>("image");
      jni::local_ref<JPAM_NativeAssetSource> image = this->getFieldValue(fieldImage);
      static const auto fieldImageSize = clazz->getField<jni::JDouble>("imageSize");
      jni::local_ref<jni::JDouble> imageSize = this->getFieldValue(fieldImageSize);
      static const auto fieldDuration = clazz->getField<jni::JDouble>("duration");
      jni::local_ref<jni::JDouble> duration = this->getFieldValue(fieldDuration);
      return PAM_ToastParams(
        message->toStdString(),
        backgroundColor->toStdString(),
        textColor->toStdString(),
        fontSize != nullptr ? std::make_optional(fontSize->value()) : std::nullopt,
        image != nullptr ? std::make_optional(image->toCpp()) : std::nullopt,
        imageSize != nullptr ? std::make_optional(imageSize->value()) : std::nullopt,
        duration != nullptr ? std::make_optional(duration->value()) : 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<JPAM_ToastParams::javaobject> fromCpp(const PAM_ToastParams& value) {
      using JSignature = JPAM_ToastParams(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JPAM_NativeAssetSource>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.message),
        jni::make_jstring(value.backgroundColor),
        jni::make_jstring(value.textColor),
        value.fontSize.has_value() ? jni::JDouble::valueOf(value.fontSize.value()) : nullptr,
        value.image.has_value() ? JPAM_NativeAssetSource::fromCpp(value.image.value()) : nullptr,
        value.imageSize.has_value() ? jni::JDouble::valueOf(value.imageSize.value()) : nullptr,
        value.duration.has_value() ? jni::JDouble::valueOf(value.duration.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::progressandmodal
