///
/// JItemSource.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 "ItemSource.hpp"

namespace margelo::nitro::aviation {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::aviation
