///
/// JPreviewResizeMode.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 "PreviewResizeMode.hpp"

namespace margelo::nitro::camera {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::camera
