///
/// JScreenOrientationValue.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 "ScreenOrientationValue.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::one
