///
/// JDocumentPickerAsset.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 "DocumentPickerAsset.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct DocumentPickerAsset by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    DocumentPickerAsset toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldUri = clazz->getField<jni::JString>("uri");
      jni::local_ref<jni::JString> uri = this->getFieldValue(fieldUri);
      static const auto fieldName = clazz->getField<jni::JString>("name");
      jni::local_ref<jni::JString> name = this->getFieldValue(fieldName);
      static const auto fieldMimeType = clazz->getField<jni::JString>("mimeType");
      jni::local_ref<jni::JString> mimeType = this->getFieldValue(fieldMimeType);
      static const auto fieldSize = clazz->getField<jni::JDouble>("size");
      jni::local_ref<jni::JDouble> size = this->getFieldValue(fieldSize);
      return DocumentPickerAsset(
        uri->toStdString(),
        name->toStdString(),
        mimeType != nullptr ? std::make_optional(mimeType->toStdString()) : std::nullopt,
        size != nullptr ? std::make_optional(size->value()) : std::nullopt
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JDocumentPickerAsset::javaobject> fromCpp(const DocumentPickerAsset& value) {
      using JSignature = JDocumentPickerAsset(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.uri),
        jni::make_jstring(value.name),
        value.mimeType.has_value() ? jni::make_jstring(value.mimeType.value()) : nullptr,
        value.size.has_value() ? jni::JDouble::valueOf(value.size.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
