///
/// JIapStore.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 "IapStore.hpp"

namespace margelo::nitro::iap {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JIapStore> fromCpp(IapStore value) {
      static const auto clazz = javaClassStatic();
      switch (value) {
        case IapStore::UNKNOWN:
          static const auto fieldUNKNOWN = clazz->getStaticField<JIapStore>("UNKNOWN");
          return clazz->getStaticFieldValue(fieldUNKNOWN);
        case IapStore::APPLE:
          static const auto fieldAPPLE = clazz->getStaticField<JIapStore>("APPLE");
          return clazz->getStaticFieldValue(fieldAPPLE);
        case IapStore::GOOGLE:
          static const auto fieldGOOGLE = clazz->getStaticField<JIapStore>("GOOGLE");
          return clazz->getStaticFieldValue(fieldGOOGLE);
        case IapStore::HORIZON:
          static const auto fieldHORIZON = clazz->getStaticField<JIapStore>("HORIZON");
          return clazz->getStaticFieldValue(fieldHORIZON);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::iap
