///
/// JProtectedStorePolicy.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 "ProtectedStorePolicy.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::one
