///
/// JOneImageFormat.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 "OneImageFormat.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::one
