///
/// JDynamicColor.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 "DynamicColor.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::inappbrowsernitro {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct DynamicColor by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    DynamicColor toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldBase = clazz->getField<jni::JString>("base");
      jni::local_ref<jni::JString> base = this->getFieldValue(fieldBase);
      static const auto fieldLight = clazz->getField<jni::JString>("light");
      jni::local_ref<jni::JString> light = this->getFieldValue(fieldLight);
      static const auto fieldDark = clazz->getField<jni::JString>("dark");
      jni::local_ref<jni::JString> dark = this->getFieldValue(fieldDark);
      static const auto fieldHighContrast = clazz->getField<jni::JString>("highContrast");
      jni::local_ref<jni::JString> highContrast = this->getFieldValue(fieldHighContrast);
      return DynamicColor(
        base != nullptr ? std::make_optional(base->toStdString()) : std::nullopt,
        light != nullptr ? std::make_optional(light->toStdString()) : std::nullopt,
        dark != nullptr ? std::make_optional(dark->toStdString()) : std::nullopt,
        highContrast != nullptr ? std::make_optional(highContrast->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<JDynamicColor::javaobject> fromCpp(const DynamicColor& value) {
      using JSignature = JDynamicColor(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,
        value.base.has_value() ? jni::make_jstring(value.base.value()) : nullptr,
        value.light.has_value() ? jni::make_jstring(value.light.value()) : nullptr,
        value.dark.has_value() ? jni::make_jstring(value.dark.value()) : nullptr,
        value.highContrast.has_value() ? jni::make_jstring(value.highContrast.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::inappbrowsernitro
