///
/// JGeneratePreviewOptions.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 "GeneratePreviewOptions.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::mediatoolkit {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct GeneratePreviewOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    GeneratePreviewOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldFps = clazz->getField<jni::JDouble>("fps");
      jni::local_ref<jni::JDouble> fps = this->getFieldValue(fieldFps);
      static const auto fieldDurationMs = clazz->getField<jni::JDouble>("durationMs");
      jni::local_ref<jni::JDouble> durationMs = this->getFieldValue(fieldDurationMs);
      static const auto fieldMaxWidth = clazz->getField<jni::JDouble>("maxWidth");
      jni::local_ref<jni::JDouble> maxWidth = this->getFieldValue(fieldMaxWidth);
      static const auto fieldQuality = clazz->getField<jni::JDouble>("quality");
      jni::local_ref<jni::JDouble> quality = this->getFieldValue(fieldQuality);
      static const auto fieldOutputPath = clazz->getField<jni::JString>("outputPath");
      jni::local_ref<jni::JString> outputPath = this->getFieldValue(fieldOutputPath);
      return GeneratePreviewOptions(
        fps != nullptr ? std::make_optional(fps->value()) : std::nullopt,
        durationMs != nullptr ? std::make_optional(durationMs->value()) : std::nullopt,
        maxWidth != nullptr ? std::make_optional(maxWidth->value()) : std::nullopt,
        quality != nullptr ? std::make_optional(quality->value()) : std::nullopt,
        outputPath != nullptr ? std::make_optional(outputPath->toStdString()) : 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<JGeneratePreviewOptions::javaobject> fromCpp(const GeneratePreviewOptions& value) {
      using JSignature = JGeneratePreviewOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.fps.has_value() ? jni::JDouble::valueOf(value.fps.value()) : nullptr,
        value.durationMs.has_value() ? jni::JDouble::valueOf(value.durationMs.value()) : nullptr,
        value.maxWidth.has_value() ? jni::JDouble::valueOf(value.maxWidth.value()) : nullptr,
        value.quality.has_value() ? jni::JDouble::valueOf(value.quality.value()) : nullptr,
        value.outputPath.has_value() ? jni::make_jstring(value.outputPath.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::mediatoolkit
