///
/// JCameraControllerConfiguration.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 "CameraControllerConfiguration.hpp"

#include <optional>

namespace margelo::nitro::camera {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct CameraControllerConfiguration by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    CameraControllerConfiguration toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldEnableLowLightBoost = clazz->getField<jni::JBoolean>("enableLowLightBoost");
      jni::local_ref<jni::JBoolean> enableLowLightBoost = this->getFieldValue(fieldEnableLowLightBoost);
      static const auto fieldEnableSmoothAutoFocus = clazz->getField<jni::JBoolean>("enableSmoothAutoFocus");
      jni::local_ref<jni::JBoolean> enableSmoothAutoFocus = this->getFieldValue(fieldEnableSmoothAutoFocus);
      static const auto fieldEnableDistortionCorrection = clazz->getField<jni::JBoolean>("enableDistortionCorrection");
      jni::local_ref<jni::JBoolean> enableDistortionCorrection = this->getFieldValue(fieldEnableDistortionCorrection);
      return CameraControllerConfiguration(
        enableLowLightBoost != nullptr ? std::make_optional(static_cast<bool>(enableLowLightBoost->value())) : std::nullopt,
        enableSmoothAutoFocus != nullptr ? std::make_optional(static_cast<bool>(enableSmoothAutoFocus->value())) : std::nullopt,
        enableDistortionCorrection != nullptr ? std::make_optional(static_cast<bool>(enableDistortionCorrection->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<JCameraControllerConfiguration::javaobject> fromCpp(const CameraControllerConfiguration& value) {
      using JSignature = JCameraControllerConfiguration(jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.enableLowLightBoost.has_value() ? jni::JBoolean::valueOf(value.enableLowLightBoost.value()) : nullptr,
        value.enableSmoothAutoFocus.has_value() ? jni::JBoolean::valueOf(value.enableSmoothAutoFocus.value()) : nullptr,
        value.enableDistortionCorrection.has_value() ? jni::JBoolean::valueOf(value.enableDistortionCorrection.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::camera
