///
/// JResizeMode.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 "ResizeMode.hpp"

namespace margelo::nitro::video {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JResizeMode> fromCpp(ResizeMode value) {
      static const auto clazz = javaClassStatic();
      static const auto fieldCONTAIN = clazz->getStaticField<JResizeMode>("CONTAIN");
      static const auto fieldCOVER = clazz->getStaticField<JResizeMode>("COVER");
      static const auto fieldSTRETCH = clazz->getStaticField<JResizeMode>("STRETCH");
      static const auto fieldNONE = clazz->getStaticField<JResizeMode>("NONE");
      
      switch (value) {
        case ResizeMode::CONTAIN:
          return clazz->getStaticFieldValue(fieldCONTAIN);
        case ResizeMode::COVER:
          return clazz->getStaticFieldValue(fieldCOVER);
        case ResizeMode::STRETCH:
          return clazz->getStaticFieldValue(fieldSTRETCH);
        case ResizeMode::NONE:
          return clazz->getStaticFieldValue(fieldNONE);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::video
