///
/// JSpeechSynthesisVoice.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 "SpeechSynthesisVoice.hpp"

#include "JSpeechSynthesisVoiceQuality.hpp"
#include "SpeechSynthesisVoiceQuality.hpp"
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct SpeechSynthesisVoice by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    SpeechSynthesisVoice toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldIdentifier = clazz->getField<jni::JString>("identifier");
      jni::local_ref<jni::JString> identifier = this->getFieldValue(fieldIdentifier);
      static const auto fieldLanguage = clazz->getField<jni::JString>("language");
      jni::local_ref<jni::JString> language = this->getFieldValue(fieldLanguage);
      static const auto fieldName = clazz->getField<jni::JString>("name");
      jni::local_ref<jni::JString> name = this->getFieldValue(fieldName);
      static const auto fieldQuality = clazz->getField<JSpeechSynthesisVoiceQuality>("quality");
      jni::local_ref<JSpeechSynthesisVoiceQuality> quality = this->getFieldValue(fieldQuality);
      return SpeechSynthesisVoice(
        identifier->toStdString(),
        language->toStdString(),
        name->toStdString(),
        quality->toCpp()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JSpeechSynthesisVoice::javaobject> fromCpp(const SpeechSynthesisVoice& value) {
      using JSignature = JSpeechSynthesisVoice(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<JSpeechSynthesisVoiceQuality>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.identifier),
        jni::make_jstring(value.language),
        jni::make_jstring(value.name),
        JSpeechSynthesisVoiceQuality::fromCpp(value.quality)
      );
    }
  };

} // namespace margelo::nitro::one
