///
/// JBluetoothPhy.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 "BluetoothPhy.hpp"

namespace margelo::nitro::munimbluetooth {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JBluetoothPhy> fromCpp(BluetoothPhy value) {
      static const auto clazz = javaClassStatic();
      switch (value) {
        case BluetoothPhy::LE1M:
          static const auto fieldLE1M = clazz->getStaticField<JBluetoothPhy>("LE1M");
          return clazz->getStaticFieldValue(fieldLE1M);
        case BluetoothPhy::LE2M:
          static const auto fieldLE2M = clazz->getStaticField<JBluetoothPhy>("LE2M");
          return clazz->getStaticFieldValue(fieldLE2M);
        case BluetoothPhy::LECODED:
          static const auto fieldLECODED = clazz->getStaticField<JBluetoothPhy>("LECODED");
          return clazz->getStaticFieldValue(fieldLECODED);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::munimbluetooth
