///
/// JNativeExternalSubtitle.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "NativeExternalSubtitle.hpp"

#include "JSubtitleType.hpp"
#include "SubtitleType.hpp"
#include <string>

namespace margelo::nitro::video {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeExternalSubtitle by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeExternalSubtitle toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldUri = clazz->getField<jni::JString>("uri");
      jni::local_ref<jni::JString> uri = this->getFieldValue(fieldUri);
      static const auto fieldLabel = clazz->getField<jni::JString>("label");
      jni::local_ref<jni::JString> label = this->getFieldValue(fieldLabel);
      static const auto fieldType = clazz->getField<JSubtitleType>("type");
      jni::local_ref<JSubtitleType> type = this->getFieldValue(fieldType);
      static const auto fieldLanguage = clazz->getField<jni::JString>("language");
      jni::local_ref<jni::JString> language = this->getFieldValue(fieldLanguage);
      return NativeExternalSubtitle(
        uri->toStdString(),
        label->toStdString(),
        type->toCpp(),
        language->toStdString()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JNativeExternalSubtitle::javaobject> fromCpp(const NativeExternalSubtitle& value) {
      return newInstance(
        jni::make_jstring(value.uri),
        jni::make_jstring(value.label),
        JSubtitleType::fromCpp(value.type),
        jni::make_jstring(value.language)
      );
    }
  };

} // namespace margelo::nitro::video
