///
/// JProcessImageOptions.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 "ProcessImageOptions.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::mediatoolkit {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct ProcessImageOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    ProcessImageOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldCropX = clazz->getField<jni::JDouble>("cropX");
      jni::local_ref<jni::JDouble> cropX = this->getFieldValue(fieldCropX);
      static const auto fieldCropY = clazz->getField<jni::JDouble>("cropY");
      jni::local_ref<jni::JDouble> cropY = this->getFieldValue(fieldCropY);
      static const auto fieldCropWidth = clazz->getField<jni::JDouble>("cropWidth");
      jni::local_ref<jni::JDouble> cropWidth = this->getFieldValue(fieldCropWidth);
      static const auto fieldCropHeight = clazz->getField<jni::JDouble>("cropHeight");
      jni::local_ref<jni::JDouble> cropHeight = this->getFieldValue(fieldCropHeight);
      static const auto fieldFlip = clazz->getField<jni::JString>("flip");
      jni::local_ref<jni::JString> flip = this->getFieldValue(fieldFlip);
      static const auto fieldRotation = clazz->getField<jni::JDouble>("rotation");
      jni::local_ref<jni::JDouble> rotation = this->getFieldValue(fieldRotation);
      static const auto fieldLutUri = clazz->getField<jni::JString>("lutUri");
      jni::local_ref<jni::JString> lutUri = this->getFieldValue(fieldLutUri);
      static const auto fieldOutputPath = clazz->getField<jni::JString>("outputPath");
      jni::local_ref<jni::JString> outputPath = this->getFieldValue(fieldOutputPath);
      static const auto fieldCornerRadius = clazz->getField<jni::JDouble>("cornerRadius");
      jni::local_ref<jni::JDouble> cornerRadius = this->getFieldValue(fieldCornerRadius);
      return ProcessImageOptions(
        cropX != nullptr ? std::make_optional(cropX->value()) : std::nullopt,
        cropY != nullptr ? std::make_optional(cropY->value()) : std::nullopt,
        cropWidth != nullptr ? std::make_optional(cropWidth->value()) : std::nullopt,
        cropHeight != nullptr ? std::make_optional(cropHeight->value()) : std::nullopt,
        flip != nullptr ? std::make_optional(flip->toStdString()) : std::nullopt,
        rotation != nullptr ? std::make_optional(rotation->value()) : std::nullopt,
        lutUri != nullptr ? std::make_optional(lutUri->toStdString()) : std::nullopt,
        outputPath != nullptr ? std::make_optional(outputPath->toStdString()) : std::nullopt,
        cornerRadius != nullptr ? std::make_optional(cornerRadius->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<JProcessImageOptions::javaobject> fromCpp(const ProcessImageOptions& value) {
      using JSignature = JProcessImageOptions(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>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JString>, 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,
        value.cropX.has_value() ? jni::JDouble::valueOf(value.cropX.value()) : nullptr,
        value.cropY.has_value() ? jni::JDouble::valueOf(value.cropY.value()) : nullptr,
        value.cropWidth.has_value() ? jni::JDouble::valueOf(value.cropWidth.value()) : nullptr,
        value.cropHeight.has_value() ? jni::JDouble::valueOf(value.cropHeight.value()) : nullptr,
        value.flip.has_value() ? jni::make_jstring(value.flip.value()) : nullptr,
        value.rotation.has_value() ? jni::JDouble::valueOf(value.rotation.value()) : nullptr,
        value.lutUri.has_value() ? jni::make_jstring(value.lutUri.value()) : nullptr,
        value.outputPath.has_value() ? jni::make_jstring(value.outputPath.value()) : nullptr,
        value.cornerRadius.has_value() ? jni::JDouble::valueOf(value.cornerRadius.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::mediatoolkit
