///
/// JPAM_ConfigParams.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_ConfigParams.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::progressandmodal {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct PAM_ConfigParams by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    PAM_ConfigParams toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldIndicatorColor = clazz->getField<jni::JString>("indicatorColor");
      jni::local_ref<jni::JString> indicatorColor = this->getFieldValue(fieldIndicatorColor);
      static const auto fieldBackgroundAlpha = clazz->getField<jni::JDouble>("backgroundAlpha");
      jni::local_ref<jni::JDouble> backgroundAlpha = this->getFieldValue(fieldBackgroundAlpha);
      return PAM_ConfigParams(
        indicatorColor != nullptr ? std::make_optional(indicatorColor->toStdString()) : std::nullopt,
        backgroundAlpha != nullptr ? std::make_optional(backgroundAlpha->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_ConfigParams::javaobject> fromCpp(const PAM_ConfigParams& value) {
      using JSignature = JPAM_ConfigParams(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.indicatorColor.has_value() ? jni::make_jstring(value.indicatorColor.value()) : nullptr,
        value.backgroundAlpha.has_value() ? jni::JDouble::valueOf(value.backgroundAlpha.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::progressandmodal
