///
/// JMutationResult.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 "MutationResult.hpp"

#include "AccessControl.hpp"
#include "JAccessControl.hpp"
#include "JSecurityLevel.hpp"
#include "JStorageBackend.hpp"
#include "JStorageMetadata.hpp"
#include "SecurityLevel.hpp"
#include "StorageBackend.hpp"
#include "StorageMetadata.hpp"
#include <optional>
#include <string>

namespace margelo::nitro::sensitiveinfo {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct MutationResult by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    MutationResult toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldMetadata = clazz->getField<JStorageMetadata>("metadata");
      jni::local_ref<JStorageMetadata> metadata = this->getFieldValue(fieldMetadata);
      return MutationResult(
        metadata->toCpp()
      );
    }

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

} // namespace margelo::nitro::sensitiveinfo
