///
/// JCapturePhotoSettings.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 "CapturePhotoSettings.hpp"

#include "FlashMode.hpp"
#include "HybridLocationSpec.hpp"
#include "JFlashMode.hpp"
#include "JHybridLocationSpec.hpp"
#include <memory>
#include <optional>

namespace margelo::nitro::camera {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct CapturePhotoSettings by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    CapturePhotoSettings toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldFlashMode = clazz->getField<JFlashMode>("flashMode");
      jni::local_ref<JFlashMode> flashMode = this->getFieldValue(fieldFlashMode);
      static const auto fieldEnableShutterSound = clazz->getField<jni::JBoolean>("enableShutterSound");
      jni::local_ref<jni::JBoolean> enableShutterSound = this->getFieldValue(fieldEnableShutterSound);
      static const auto fieldEnableDepthData = clazz->getField<jni::JBoolean>("enableDepthData");
      jni::local_ref<jni::JBoolean> enableDepthData = this->getFieldValue(fieldEnableDepthData);
      static const auto fieldEnableRedEyeReduction = clazz->getField<jni::JBoolean>("enableRedEyeReduction");
      jni::local_ref<jni::JBoolean> enableRedEyeReduction = this->getFieldValue(fieldEnableRedEyeReduction);
      static const auto fieldEnableCameraCalibrationDataDelivery = clazz->getField<jni::JBoolean>("enableCameraCalibrationDataDelivery");
      jni::local_ref<jni::JBoolean> enableCameraCalibrationDataDelivery = this->getFieldValue(fieldEnableCameraCalibrationDataDelivery);
      static const auto fieldEnableDistortionCorrection = clazz->getField<jni::JBoolean>("enableDistortionCorrection");
      jni::local_ref<jni::JBoolean> enableDistortionCorrection = this->getFieldValue(fieldEnableDistortionCorrection);
      static const auto fieldEnableVirtualDeviceFusion = clazz->getField<jni::JBoolean>("enableVirtualDeviceFusion");
      jni::local_ref<jni::JBoolean> enableVirtualDeviceFusion = this->getFieldValue(fieldEnableVirtualDeviceFusion);
      static const auto fieldLocation = clazz->getField<JHybridLocationSpec::JavaPart>("location");
      jni::local_ref<JHybridLocationSpec::JavaPart> location = this->getFieldValue(fieldLocation);
      return CapturePhotoSettings(
        flashMode != nullptr ? std::make_optional(flashMode->toCpp()) : std::nullopt,
        enableShutterSound != nullptr ? std::make_optional(static_cast<bool>(enableShutterSound->value())) : std::nullopt,
        enableDepthData != nullptr ? std::make_optional(static_cast<bool>(enableDepthData->value())) : std::nullopt,
        enableRedEyeReduction != nullptr ? std::make_optional(static_cast<bool>(enableRedEyeReduction->value())) : std::nullopt,
        enableCameraCalibrationDataDelivery != nullptr ? std::make_optional(static_cast<bool>(enableCameraCalibrationDataDelivery->value())) : std::nullopt,
        enableDistortionCorrection != nullptr ? std::make_optional(static_cast<bool>(enableDistortionCorrection->value())) : std::nullopt,
        enableVirtualDeviceFusion != nullptr ? std::make_optional(static_cast<bool>(enableVirtualDeviceFusion->value())) : std::nullopt,
        location != nullptr ? std::make_optional(location->getJHybridLocationSpec()) : 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<JCapturePhotoSettings::javaobject> fromCpp(const CapturePhotoSettings& value) {
      using JSignature = JCapturePhotoSettings(jni::alias_ref<JFlashMode>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JHybridLocationSpec::JavaPart>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.flashMode.has_value() ? JFlashMode::fromCpp(value.flashMode.value()) : nullptr,
        value.enableShutterSound.has_value() ? jni::JBoolean::valueOf(value.enableShutterSound.value()) : nullptr,
        value.enableDepthData.has_value() ? jni::JBoolean::valueOf(value.enableDepthData.value()) : nullptr,
        value.enableRedEyeReduction.has_value() ? jni::JBoolean::valueOf(value.enableRedEyeReduction.value()) : nullptr,
        value.enableCameraCalibrationDataDelivery.has_value() ? jni::JBoolean::valueOf(value.enableCameraCalibrationDataDelivery.value()) : nullptr,
        value.enableDistortionCorrection.has_value() ? jni::JBoolean::valueOf(value.enableDistortionCorrection.value()) : nullptr,
        value.enableVirtualDeviceFusion.has_value() ? jni::JBoolean::valueOf(value.enableVirtualDeviceFusion.value()) : nullptr,
        value.location.has_value() ? std::dynamic_pointer_cast<JHybridLocationSpec>(value.location.value())->getJavaPart() : nullptr
      );
    }
  };

} // namespace margelo::nitro::camera
