///
/// JSpeechStartOptions.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 "SpeechStartOptions.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

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

} // namespace margelo::nitro::one
