///
/// JImagePickerAsset.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 "ImagePickerAsset.hpp"

#include "ImagePickerAssetType.hpp"
#include "JImagePickerAssetType.hpp"
#include <optional>
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct ImagePickerAsset by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    ImagePickerAsset 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 fieldWidth = clazz->getField<double>("width");
      double width = this->getFieldValue(fieldWidth);
      static const auto fieldHeight = clazz->getField<double>("height");
      double height = this->getFieldValue(fieldHeight);
      static const auto fieldMimeType = clazz->getField<jni::JString>("mimeType");
      jni::local_ref<jni::JString> mimeType = this->getFieldValue(fieldMimeType);
      static const auto fieldFileName = clazz->getField<jni::JString>("fileName");
      jni::local_ref<jni::JString> fileName = this->getFieldValue(fieldFileName);
      static const auto fieldFileSize = clazz->getField<jni::JDouble>("fileSize");
      jni::local_ref<jni::JDouble> fileSize = this->getFieldValue(fieldFileSize);
      static const auto fieldDuration = clazz->getField<jni::JDouble>("duration");
      jni::local_ref<jni::JDouble> duration = this->getFieldValue(fieldDuration);
      static const auto fieldType = clazz->getField<JImagePickerAssetType>("type");
      jni::local_ref<JImagePickerAssetType> type = this->getFieldValue(fieldType);
      return ImagePickerAsset(
        uri->toStdString(),
        width,
        height,
        mimeType != nullptr ? std::make_optional(mimeType->toStdString()) : std::nullopt,
        fileName != nullptr ? std::make_optional(fileName->toStdString()) : std::nullopt,
        fileSize != nullptr ? std::make_optional(fileSize->value()) : std::nullopt,
        duration != nullptr ? std::make_optional(duration->value()) : std::nullopt,
        type != nullptr ? std::make_optional(type->toCpp()) : 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<JImagePickerAsset::javaobject> fromCpp(const ImagePickerAsset& value) {
      using JSignature = JImagePickerAsset(jni::alias_ref<jni::JString>, double, double, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JImagePickerAssetType>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.uri),
        value.width,
        value.height,
        value.mimeType.has_value() ? jni::make_jstring(value.mimeType.value()) : nullptr,
        value.fileName.has_value() ? jni::make_jstring(value.fileName.value()) : nullptr,
        value.fileSize.has_value() ? jni::JDouble::valueOf(value.fileSize.value()) : nullptr,
        value.duration.has_value() ? jni::JDouble::valueOf(value.duration.value()) : nullptr,
        value.type.has_value() ? JImagePickerAssetType::fromCpp(value.type.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
