///
/// JSecurityAvailability.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 "SecurityAvailability.hpp"

#include "BiometryStatus.hpp"
#include "JBiometryStatus.hpp"

namespace margelo::nitro::sensitiveinfo {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct SecurityAvailability by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    SecurityAvailability toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldSecureEnclave = clazz->getField<jboolean>("secureEnclave");
      jboolean secureEnclave = this->getFieldValue(fieldSecureEnclave);
      static const auto fieldStrongBox = clazz->getField<jboolean>("strongBox");
      jboolean strongBox = this->getFieldValue(fieldStrongBox);
      static const auto fieldBiometry = clazz->getField<jboolean>("biometry");
      jboolean biometry = this->getFieldValue(fieldBiometry);
      static const auto fieldBiometryStatus = clazz->getField<JBiometryStatus>("biometryStatus");
      jni::local_ref<JBiometryStatus> biometryStatus = this->getFieldValue(fieldBiometryStatus);
      static const auto fieldDeviceCredential = clazz->getField<jboolean>("deviceCredential");
      jboolean deviceCredential = this->getFieldValue(fieldDeviceCredential);
      return SecurityAvailability(
        static_cast<bool>(secureEnclave),
        static_cast<bool>(strongBox),
        static_cast<bool>(biometry),
        biometryStatus->toCpp(),
        static_cast<bool>(deviceCredential)
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JSecurityAvailability::javaobject> fromCpp(const SecurityAvailability& value) {
      using JSignature = JSecurityAvailability(jboolean, jboolean, jboolean, jni::alias_ref<JBiometryStatus>, jboolean);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.secureEnclave,
        value.strongBox,
        value.biometry,
        JBiometryStatus::fromCpp(value.biometryStatus),
        value.deviceCredential
      );
    }
  };

} // namespace margelo::nitro::sensitiveinfo
