///
/// JClipboardGetImageOptions.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 "ClipboardGetImageOptions.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct ClipboardGetImageOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    ClipboardGetImageOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldFormat = clazz->getField<jni::JString>("format");
      jni::local_ref<jni::JString> format = this->getFieldValue(fieldFormat);
      static const auto fieldJpegQuality = clazz->getField<jni::JDouble>("jpegQuality");
      jni::local_ref<jni::JDouble> jpegQuality = this->getFieldValue(fieldJpegQuality);
      return ClipboardGetImageOptions(
        format->toStdString(),
        jpegQuality != nullptr ? std::make_optional(jpegQuality->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<JClipboardGetImageOptions::javaobject> fromCpp(const ClipboardGetImageOptions& value) {
      using JSignature = JClipboardGetImageOptions(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.format),
        value.jpegQuality.has_value() ? jni::JDouble::valueOf(value.jpegQuality.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
