///
/// JSubtitleType.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 "SubtitleType.hpp"

namespace margelo::nitro::video {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based enum to the C++ enum SubtitleType.
     */
    [[maybe_unused]]
    [[nodiscard]]
    SubtitleType toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldOrdinal = clazz->getField<int>("value");
      int ordinal = this->getFieldValue(fieldOrdinal);
      return static_cast<SubtitleType>(ordinal);
    }

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JSubtitleType> fromCpp(SubtitleType value) {
      static const auto clazz = javaClassStatic();
      static const auto fieldAUTO = clazz->getStaticField<JSubtitleType>("AUTO");
      static const auto fieldVTT = clazz->getStaticField<JSubtitleType>("VTT");
      static const auto fieldSRT = clazz->getStaticField<JSubtitleType>("SRT");
      static const auto fieldSSA = clazz->getStaticField<JSubtitleType>("SSA");
      static const auto fieldASS = clazz->getStaticField<JSubtitleType>("ASS");
      
      switch (value) {
        case SubtitleType::AUTO:
          return clazz->getStaticFieldValue(fieldAUTO);
        case SubtitleType::VTT:
          return clazz->getStaticFieldValue(fieldVTT);
        case SubtitleType::SRT:
          return clazz->getStaticFieldValue(fieldSRT);
        case SubtitleType::SSA:
          return clazz->getStaticFieldValue(fieldSSA);
        case SubtitleType::ASS:
          return clazz->getStaticFieldValue(fieldASS);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::video
