///
/// JDfuState.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 "DfuState.hpp"

namespace margelo::nitro::co::zyke::dfu {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JDfuState> fromCpp(DfuState value) {
      static const auto clazz = javaClassStatic();
      switch (value) {
        case DfuState::CONNECTING:
          static const auto fieldCONNECTING = clazz->getStaticField<JDfuState>("CONNECTING");
          return clazz->getStaticFieldValue(fieldCONNECTING);
        case DfuState::STARTING:
          static const auto fieldSTARTING = clazz->getStaticField<JDfuState>("STARTING");
          return clazz->getStaticFieldValue(fieldSTARTING);
        case DfuState::ENABLINGDFUMODE:
          static const auto fieldENABLINGDFUMODE = clazz->getStaticField<JDfuState>("ENABLINGDFUMODE");
          return clazz->getStaticFieldValue(fieldENABLINGDFUMODE);
        case DfuState::UPLOADING:
          static const auto fieldUPLOADING = clazz->getStaticField<JDfuState>("UPLOADING");
          return clazz->getStaticFieldValue(fieldUPLOADING);
        case DfuState::VALIDATING:
          static const auto fieldVALIDATING = clazz->getStaticField<JDfuState>("VALIDATING");
          return clazz->getStaticFieldValue(fieldVALIDATING);
        case DfuState::DISCONNECTING:
          static const auto fieldDISCONNECTING = clazz->getStaticField<JDfuState>("DISCONNECTING");
          return clazz->getStaticFieldValue(fieldDISCONNECTING);
        case DfuState::COMPLETED:
          static const auto fieldCOMPLETED = clazz->getStaticField<JDfuState>("COMPLETED");
          return clazz->getStaticFieldValue(fieldCOMPLETED);
        case DfuState::ABORTED:
          static const auto fieldABORTED = clazz->getStaticField<JDfuState>("ABORTED");
          return clazz->getStaticFieldValue(fieldABORTED);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::co::zyke::dfu
