///
/// JTtffSource.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 "TtffSource.hpp"

namespace margelo::nitro::aviation {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::aviation
