///
/// JBondState.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 "BondState.hpp"

namespace margelo::nitro::munimbluetooth {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JBondState> fromCpp(BondState value) {
      static const auto clazz = javaClassStatic();
      switch (value) {
        case BondState::NONE:
          static const auto fieldNONE = clazz->getStaticField<JBondState>("NONE");
          return clazz->getStaticFieldValue(fieldNONE);
        case BondState::BONDING:
          static const auto fieldBONDING = clazz->getStaticField<JBondState>("BONDING");
          return clazz->getStaticFieldValue(fieldBONDING);
        case BondState::BONDED:
          static const auto fieldBONDED = clazz->getStaticField<JBondState>("BONDED");
          return clazz->getStaticFieldValue(fieldBONDED);
        case BondState::UNSUPPORTED:
          static const auto fieldUNSUPPORTED = clazz->getStaticField<JBondState>("UNSUPPORTED");
          return clazz->getStaticFieldValue(fieldUNSUPPORTED);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::munimbluetooth
