///
/// JCameraDevice.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "CameraDevice.hpp"

namespace margelo::nitro::multipleimagepicker {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::multipleimagepicker
