///
/// JSecurityLevel.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 "SecurityLevel.hpp"

namespace margelo::nitro::sensitiveinfo {

  using namespace facebook;

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

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

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JSecurityLevel> fromCpp(SecurityLevel value) {
      static const auto clazz = javaClassStatic();
      switch (value) {
        case SecurityLevel::SECUREENCLAVE:
          static const auto fieldSECUREENCLAVE = clazz->getStaticField<JSecurityLevel>("SECUREENCLAVE");
          return clazz->getStaticFieldValue(fieldSECUREENCLAVE);
        case SecurityLevel::STRONGBOX:
          static const auto fieldSTRONGBOX = clazz->getStaticField<JSecurityLevel>("STRONGBOX");
          return clazz->getStaticFieldValue(fieldSTRONGBOX);
        case SecurityLevel::BIOMETRY:
          static const auto fieldBIOMETRY = clazz->getStaticField<JSecurityLevel>("BIOMETRY");
          return clazz->getStaticFieldValue(fieldBIOMETRY);
        case SecurityLevel::DEVICECREDENTIAL:
          static const auto fieldDEVICECREDENTIAL = clazz->getStaticField<JSecurityLevel>("DEVICECREDENTIAL");
          return clazz->getStaticFieldValue(fieldDEVICECREDENTIAL);
        case SecurityLevel::SOFTWARE:
          static const auto fieldSOFTWARE = clazz->getStaticField<JSecurityLevel>("SOFTWARE");
          return clazz->getStaticFieldValue(fieldSOFTWARE);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::sensitiveinfo
