///
/// JExposureMode.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 "ExposureMode.hpp"

namespace margelo::nitro::camera {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JExposureMode> fromCpp(ExposureMode value) {
      static const auto clazz = javaClassStatic();
      switch (value) {
        case ExposureMode::LOCKED:
          static const auto fieldLOCKED = clazz->getStaticField<JExposureMode>("LOCKED");
          return clazz->getStaticFieldValue(fieldLOCKED);
        case ExposureMode::AUTO_EXPOSURE:
          static const auto fieldAUTO_EXPOSURE = clazz->getStaticField<JExposureMode>("AUTO_EXPOSURE");
          return clazz->getStaticFieldValue(fieldAUTO_EXPOSURE);
        case ExposureMode::CONTINUOUS_AUTO_EXPOSURE:
          static const auto fieldCONTINUOUS_AUTO_EXPOSURE = clazz->getStaticField<JExposureMode>("CONTINUOUS_AUTO_EXPOSURE");
          return clazz->getStaticFieldValue(fieldCONTINUOUS_AUTO_EXPOSURE);
        case ExposureMode::CUSTOM:
          static const auto fieldCUSTOM = clazz->getStaticField<JExposureMode>("CUSTOM");
          return clazz->getStaticFieldValue(fieldCUSTOM);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::camera
