///
/// JFlipOptions.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 "FlipOptions.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::mediatoolkit {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct FlipOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    FlipOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldDirection = clazz->getField<jni::JString>("direction");
      jni::local_ref<jni::JString> direction = this->getFieldValue(fieldDirection);
      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 FlipOptions(
        direction->toStdString(),
        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<JFlipOptions::javaobject> fromCpp(const FlipOptions& value) {
      using JSignature = JFlipOptions(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,
        jni::make_jstring(value.direction),
        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
