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

#pragma once

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

namespace margelo::nitro::nitrotexttospeech {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JEventName> fromCpp(EventName value) {
      static const auto clazz = javaClassStatic();
      static const auto fieldWORD = clazz->getStaticField<JEventName>("WORD");
      static const auto fieldFINISH = clazz->getStaticField<JEventName>("FINISH");
      static const auto fieldSTART = clazz->getStaticField<JEventName>("START");
      
      switch (value) {
        case EventName::WORD:
          return clazz->getStaticFieldValue(fieldWORD);
        case EventName::FINISH:
          return clazz->getStaticFieldValue(fieldFINISH);
        case EventName::START:
          return clazz->getStaticFieldValue(fieldSTART);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::nitrotexttospeech
