///
/// JFaceDetectorOptions.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 "FaceDetectorOptions.hpp"

#include "CameraPosition.hpp"
#include "JCameraPosition.hpp"
#include "JPerformanceMode.hpp"
#include "PerformanceMode.hpp"
#include <optional>

namespace margelo::nitro::camera::facedetector {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct FaceDetectorOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    FaceDetectorOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldCameraFacing = clazz->getField<JCameraPosition>("cameraFacing");
      jni::local_ref<JCameraPosition> cameraFacing = this->getFieldValue(fieldCameraFacing);
      static const auto fieldAutoMode = clazz->getField<jni::JBoolean>("autoMode");
      jni::local_ref<jni::JBoolean> autoMode = this->getFieldValue(fieldAutoMode);
      static const auto fieldWindowWidth = clazz->getField<jni::JDouble>("windowWidth");
      jni::local_ref<jni::JDouble> windowWidth = this->getFieldValue(fieldWindowWidth);
      static const auto fieldWindowHeight = clazz->getField<jni::JDouble>("windowHeight");
      jni::local_ref<jni::JDouble> windowHeight = this->getFieldValue(fieldWindowHeight);
      static const auto fieldPerformanceMode = clazz->getField<JPerformanceMode>("performanceMode");
      jni::local_ref<JPerformanceMode> performanceMode = this->getFieldValue(fieldPerformanceMode);
      static const auto fieldRunLandmarks = clazz->getField<jni::JBoolean>("runLandmarks");
      jni::local_ref<jni::JBoolean> runLandmarks = this->getFieldValue(fieldRunLandmarks);
      static const auto fieldRunContours = clazz->getField<jni::JBoolean>("runContours");
      jni::local_ref<jni::JBoolean> runContours = this->getFieldValue(fieldRunContours);
      static const auto fieldRunClassifications = clazz->getField<jni::JBoolean>("runClassifications");
      jni::local_ref<jni::JBoolean> runClassifications = this->getFieldValue(fieldRunClassifications);
      static const auto fieldMinFaceSize = clazz->getField<jni::JDouble>("minFaceSize");
      jni::local_ref<jni::JDouble> minFaceSize = this->getFieldValue(fieldMinFaceSize);
      static const auto fieldTrackingEnabled = clazz->getField<jni::JBoolean>("trackingEnabled");
      jni::local_ref<jni::JBoolean> trackingEnabled = this->getFieldValue(fieldTrackingEnabled);
      return FaceDetectorOptions(
        cameraFacing != nullptr ? std::make_optional(cameraFacing->toCpp()) : std::nullopt,
        autoMode != nullptr ? std::make_optional(static_cast<bool>(autoMode->value())) : std::nullopt,
        windowWidth != nullptr ? std::make_optional(windowWidth->value()) : std::nullopt,
        windowHeight != nullptr ? std::make_optional(windowHeight->value()) : std::nullopt,
        performanceMode != nullptr ? std::make_optional(performanceMode->toCpp()) : std::nullopt,
        runLandmarks != nullptr ? std::make_optional(static_cast<bool>(runLandmarks->value())) : std::nullopt,
        runContours != nullptr ? std::make_optional(static_cast<bool>(runContours->value())) : std::nullopt,
        runClassifications != nullptr ? std::make_optional(static_cast<bool>(runClassifications->value())) : std::nullopt,
        minFaceSize != nullptr ? std::make_optional(minFaceSize->value()) : std::nullopt,
        trackingEnabled != nullptr ? std::make_optional(static_cast<bool>(trackingEnabled->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<JFaceDetectorOptions::javaobject> fromCpp(const FaceDetectorOptions& value) {
      using JSignature = JFaceDetectorOptions(jni::alias_ref<JCameraPosition>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JPerformanceMode>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JBoolean>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.cameraFacing.has_value() ? JCameraPosition::fromCpp(value.cameraFacing.value()) : nullptr,
        value.autoMode.has_value() ? jni::JBoolean::valueOf(value.autoMode.value()) : nullptr,
        value.windowWidth.has_value() ? jni::JDouble::valueOf(value.windowWidth.value()) : nullptr,
        value.windowHeight.has_value() ? jni::JDouble::valueOf(value.windowHeight.value()) : nullptr,
        value.performanceMode.has_value() ? JPerformanceMode::fromCpp(value.performanceMode.value()) : nullptr,
        value.runLandmarks.has_value() ? jni::JBoolean::valueOf(value.runLandmarks.value()) : nullptr,
        value.runContours.has_value() ? jni::JBoolean::valueOf(value.runContours.value()) : nullptr,
        value.runClassifications.has_value() ? jni::JBoolean::valueOf(value.runClassifications.value()) : nullptr,
        value.minFaceSize.has_value() ? jni::JDouble::valueOf(value.minFaceSize.value()) : nullptr,
        value.trackingEnabled.has_value() ? jni::JBoolean::valueOf(value.trackingEnabled.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::camera::facedetector
