///
/// JTargetVideoPixelFormat.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 "TargetVideoPixelFormat.hpp"

namespace margelo::nitro::camera {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::camera
