///
/// JVideoCropOptions.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 "VideoCropOptions.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::mediatoolkit {

  using namespace facebook;

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

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

} // namespace margelo::nitro::mediatoolkit
