///
/// JTorchMode.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 "TorchMode.hpp"

namespace margelo::nitro::camera {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::camera
