///
/// JJassubAssets.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 "JassubAssets.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::omni {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct JassubAssets by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    JassubAssets toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldWorkerUrl = clazz->getField<jni::JString>("workerUrl");
      jni::local_ref<jni::JString> workerUrl = this->getFieldValue(fieldWorkerUrl);
      static const auto fieldWasmUrl = clazz->getField<jni::JString>("wasmUrl");
      jni::local_ref<jni::JString> wasmUrl = this->getFieldValue(fieldWasmUrl);
      static const auto fieldModernWasmUrl = clazz->getField<jni::JString>("modernWasmUrl");
      jni::local_ref<jni::JString> modernWasmUrl = this->getFieldValue(fieldModernWasmUrl);
      static const auto fieldFontUrl = clazz->getField<jni::JString>("fontUrl");
      jni::local_ref<jni::JString> fontUrl = this->getFieldValue(fieldFontUrl);
      return JassubAssets(
        workerUrl != nullptr ? std::make_optional(workerUrl->toStdString()) : std::nullopt,
        wasmUrl != nullptr ? std::make_optional(wasmUrl->toStdString()) : std::nullopt,
        modernWasmUrl != nullptr ? std::make_optional(modernWasmUrl->toStdString()) : std::nullopt,
        fontUrl != nullptr ? std::make_optional(fontUrl->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<JJassubAssets::javaobject> fromCpp(const JassubAssets& value) {
      using JSignature = JJassubAssets(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.workerUrl.has_value() ? jni::make_jstring(value.workerUrl.value()) : nullptr,
        value.wasmUrl.has_value() ? jni::make_jstring(value.wasmUrl.value()) : nullptr,
        value.modernWasmUrl.has_value() ? jni::make_jstring(value.modernWasmUrl.value()) : nullptr,
        value.fontUrl.has_value() ? jni::make_jstring(value.fontUrl.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::omni
