///
/// JTrimOptions.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 "TrimOptions.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::mediatoolkit {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct TrimOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    TrimOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldStartTime = clazz->getField<double>("startTime");
      double startTime = this->getFieldValue(fieldStartTime);
      static const auto fieldEndTime = clazz->getField<double>("endTime");
      double endTime = this->getFieldValue(fieldEndTime);
      static const auto fieldOutputPath = clazz->getField<jni::JString>("outputPath");
      jni::local_ref<jni::JString> outputPath = this->getFieldValue(fieldOutputPath);
      return TrimOptions(
        startTime,
        endTime,
        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<JTrimOptions::javaobject> fromCpp(const TrimOptions& value) {
      using JSignature = JTrimOptions(double, double, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.startTime,
        value.endTime,
        value.outputPath.has_value() ? jni::make_jstring(value.outputPath.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::mediatoolkit
