///
/// JSpeechErrorCode.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 "SpeechErrorCode.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JSpeechErrorCode> fromCpp(SpeechErrorCode value) {
      static const auto clazz = javaClassStatic();
      switch (value) {
        case SpeechErrorCode::UNKNOWN:
          static const auto fieldUNKNOWN = clazz->getStaticField<JSpeechErrorCode>("UNKNOWN");
          return clazz->getStaticFieldValue(fieldUNKNOWN);
        case SpeechErrorCode::NOT_ALLOWED:
          static const auto fieldNOT_ALLOWED = clazz->getStaticField<JSpeechErrorCode>("NOT_ALLOWED");
          return clazz->getStaticFieldValue(fieldNOT_ALLOWED);
        case SpeechErrorCode::SERVICE_NOT_ALLOWED:
          static const auto fieldSERVICE_NOT_ALLOWED = clazz->getStaticField<JSpeechErrorCode>("SERVICE_NOT_ALLOWED");
          return clazz->getStaticFieldValue(fieldSERVICE_NOT_ALLOWED);
        case SpeechErrorCode::LANGUAGE_NOT_SUPPORTED:
          static const auto fieldLANGUAGE_NOT_SUPPORTED = clazz->getStaticField<JSpeechErrorCode>("LANGUAGE_NOT_SUPPORTED");
          return clazz->getStaticFieldValue(fieldLANGUAGE_NOT_SUPPORTED);
        case SpeechErrorCode::AUDIO_CAPTURE:
          static const auto fieldAUDIO_CAPTURE = clazz->getStaticField<JSpeechErrorCode>("AUDIO_CAPTURE");
          return clazz->getStaticFieldValue(fieldAUDIO_CAPTURE);
        case SpeechErrorCode::INTERRUPTED:
          static const auto fieldINTERRUPTED = clazz->getStaticField<JSpeechErrorCode>("INTERRUPTED");
          return clazz->getStaticFieldValue(fieldINTERRUPTED);
        case SpeechErrorCode::NETWORK:
          static const auto fieldNETWORK = clazz->getStaticField<JSpeechErrorCode>("NETWORK");
          return clazz->getStaticFieldValue(fieldNETWORK);
        case SpeechErrorCode::BUSY:
          static const auto fieldBUSY = clazz->getStaticField<JSpeechErrorCode>("BUSY");
          return clazz->getStaticFieldValue(fieldBUSY);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::one
