///
/// JBrowserResult.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 "BrowserResult.hpp"

#include "BrowserResultType.hpp"
#include "JBrowserResultType.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct BrowserResult by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    BrowserResult toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldType = clazz->getField<JBrowserResultType>("type");
      jni::local_ref<JBrowserResultType> type = this->getFieldValue(fieldType);
      return BrowserResult(
        type->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<JBrowserResult::javaobject> fromCpp(const BrowserResult& value) {
      using JSignature = JBrowserResult(jni::alias_ref<JBrowserResultType>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JBrowserResultType::fromCpp(value.type)
      );
    }
  };

} // namespace margelo::nitro::one
