///
/// JCompressVideoOptions.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 "CompressVideoOptions.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::mediatoolkit {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct CompressVideoOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    CompressVideoOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldTargetSizeInMB = clazz->getField<jni::JDouble>("targetSizeInMB");
      jni::local_ref<jni::JDouble> targetSizeInMB = this->getFieldValue(fieldTargetSizeInMB);
      static const auto fieldMinResolution = clazz->getField<jni::JDouble>("minResolution");
      jni::local_ref<jni::JDouble> minResolution = this->getFieldValue(fieldMinResolution);
      static const auto fieldQuality = clazz->getField<jni::JString>("quality");
      jni::local_ref<jni::JString> quality = this->getFieldValue(fieldQuality);
      static const auto fieldBitrate = clazz->getField<jni::JDouble>("bitrate");
      jni::local_ref<jni::JDouble> bitrate = this->getFieldValue(fieldBitrate);
      static const auto fieldWidth = clazz->getField<jni::JDouble>("width");
      jni::local_ref<jni::JDouble> width = this->getFieldValue(fieldWidth);
      static const auto fieldMuteAudio = clazz->getField<jni::JBoolean>("muteAudio");
      jni::local_ref<jni::JBoolean> muteAudio = this->getFieldValue(fieldMuteAudio);
      static const auto fieldOutputPath = clazz->getField<jni::JString>("outputPath");
      jni::local_ref<jni::JString> outputPath = this->getFieldValue(fieldOutputPath);
      return CompressVideoOptions(
        targetSizeInMB != nullptr ? std::make_optional(targetSizeInMB->value()) : std::nullopt,
        minResolution != nullptr ? std::make_optional(minResolution->value()) : std::nullopt,
        quality != nullptr ? std::make_optional(quality->toStdString()) : std::nullopt,
        bitrate != nullptr ? std::make_optional(bitrate->value()) : std::nullopt,
        width != nullptr ? std::make_optional(width->value()) : std::nullopt,
        muteAudio != nullptr ? std::make_optional(static_cast<bool>(muteAudio->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<JCompressVideoOptions::javaobject> fromCpp(const CompressVideoOptions& value) {
      using JSignature = JCompressVideoOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.targetSizeInMB.has_value() ? jni::JDouble::valueOf(value.targetSizeInMB.value()) : nullptr,
        value.minResolution.has_value() ? jni::JDouble::valueOf(value.minResolution.value()) : nullptr,
        value.quality.has_value() ? jni::make_jstring(value.quality.value()) : nullptr,
        value.bitrate.has_value() ? jni::JDouble::valueOf(value.bitrate.value()) : nullptr,
        value.width.has_value() ? jni::JDouble::valueOf(value.width.value()) : nullptr,
        value.muteAudio.has_value() ? jni::JBoolean::valueOf(value.muteAudio.value()) : nullptr,
        value.outputPath.has_value() ? jni::make_jstring(value.outputPath.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::mediatoolkit
