///
/// JSourceType.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "SourceType.hpp"

namespace margelo::nitro::video {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::video
