///
/// JAlternativeBillingModeAndroid.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 "AlternativeBillingModeAndroid.hpp"

namespace margelo::nitro::iap {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::iap
