///
/// JVideoOrientation.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 "VideoOrientation.hpp"

namespace margelo::nitro::video {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JVideoOrientation> fromCpp(VideoOrientation value) {
      static const auto clazz = javaClassStatic();
      static const auto fieldPORTRAIT = clazz->getStaticField<JVideoOrientation>("PORTRAIT");
      static const auto fieldLANDSCAPE = clazz->getStaticField<JVideoOrientation>("LANDSCAPE");
      static const auto fieldPORTRAIT_UPSIDE_DOWN = clazz->getStaticField<JVideoOrientation>("PORTRAIT_UPSIDE_DOWN");
      static const auto fieldLANDSCAPE_LEFT = clazz->getStaticField<JVideoOrientation>("LANDSCAPE_LEFT");
      static const auto fieldLANDSCAPE_RIGHT = clazz->getStaticField<JVideoOrientation>("LANDSCAPE_RIGHT");
      static const auto fieldSQUARE = clazz->getStaticField<JVideoOrientation>("SQUARE");
      static const auto fieldUNKNOWN = clazz->getStaticField<JVideoOrientation>("UNKNOWN");
      
      switch (value) {
        case VideoOrientation::PORTRAIT:
          return clazz->getStaticFieldValue(fieldPORTRAIT);
        case VideoOrientation::LANDSCAPE:
          return clazz->getStaticFieldValue(fieldLANDSCAPE);
        case VideoOrientation::PORTRAIT_UPSIDE_DOWN:
          return clazz->getStaticFieldValue(fieldPORTRAIT_UPSIDE_DOWN);
        case VideoOrientation::LANDSCAPE_LEFT:
          return clazz->getStaticFieldValue(fieldLANDSCAPE_LEFT);
        case VideoOrientation::LANDSCAPE_RIGHT:
          return clazz->getStaticFieldValue(fieldLANDSCAPE_RIGHT);
        case VideoOrientation::SQUARE:
          return clazz->getStaticFieldValue(fieldSQUARE);
        case VideoOrientation::UNKNOWN:
          return clazz->getStaticFieldValue(fieldUNKNOWN);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::video
