///
/// JScanMode.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 "ScanMode.hpp"

namespace margelo::nitro::munimbluetooth {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JScanMode> fromCpp(ScanMode value) {
      static const auto clazz = javaClassStatic();
      switch (value) {
        case ScanMode::LOWPOWER:
          static const auto fieldLOWPOWER = clazz->getStaticField<JScanMode>("LOWPOWER");
          return clazz->getStaticFieldValue(fieldLOWPOWER);
        case ScanMode::BALANCED:
          static const auto fieldBALANCED = clazz->getStaticField<JScanMode>("BALANCED");
          return clazz->getStaticFieldValue(fieldBALANCED);
        case ScanMode::LOWLATENCY:
          static const auto fieldLOWLATENCY = clazz->getStaticField<JScanMode>("LOWLATENCY");
          return clazz->getStaticFieldValue(fieldLOWLATENCY);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::munimbluetooth
