///
/// JVideoPlayerStatus.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 "VideoPlayerStatus.hpp"

namespace margelo::nitro::video {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JVideoPlayerStatus> fromCpp(VideoPlayerStatus value) {
      static const auto clazz = javaClassStatic();
      static const auto fieldIDLE = clazz->getStaticField<JVideoPlayerStatus>("IDLE");
      static const auto fieldLOADING = clazz->getStaticField<JVideoPlayerStatus>("LOADING");
      static const auto fieldREADYTOPLAY = clazz->getStaticField<JVideoPlayerStatus>("READYTOPLAY");
      static const auto fieldERROR = clazz->getStaticField<JVideoPlayerStatus>("ERROR");
      
      switch (value) {
        case VideoPlayerStatus::IDLE:
          return clazz->getStaticFieldValue(fieldIDLE);
        case VideoPlayerStatus::LOADING:
          return clazz->getStaticFieldValue(fieldLOADING);
        case VideoPlayerStatus::READYTOPLAY:
          return clazz->getStaticFieldValue(fieldREADYTOPLAY);
        case VideoPlayerStatus::ERROR:
          return clazz->getStaticFieldValue(fieldERROR);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::video
