///
/// JScreenOrientation.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "ScreenOrientation.hpp"

namespace margelo::nitro::stylesheet {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::stylesheet
