///
/// JLandmarks.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 "Landmarks.hpp"

#include "JPoint.hpp"
#include "Point.hpp"
#include <optional>

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

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct Landmarks by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    Landmarks toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldLEFT_CHEEK = clazz->getField<JPoint>("LEFT_CHEEK");
      jni::local_ref<JPoint> LEFT_CHEEK = this->getFieldValue(fieldLEFT_CHEEK);
      static const auto fieldLEFT_EAR = clazz->getField<JPoint>("LEFT_EAR");
      jni::local_ref<JPoint> LEFT_EAR = this->getFieldValue(fieldLEFT_EAR);
      static const auto fieldLEFT_EYE = clazz->getField<JPoint>("LEFT_EYE");
      jni::local_ref<JPoint> LEFT_EYE = this->getFieldValue(fieldLEFT_EYE);
      static const auto fieldMOUTH_BOTTOM = clazz->getField<JPoint>("MOUTH_BOTTOM");
      jni::local_ref<JPoint> MOUTH_BOTTOM = this->getFieldValue(fieldMOUTH_BOTTOM);
      static const auto fieldMOUTH_LEFT = clazz->getField<JPoint>("MOUTH_LEFT");
      jni::local_ref<JPoint> MOUTH_LEFT = this->getFieldValue(fieldMOUTH_LEFT);
      static const auto fieldMOUTH_RIGHT = clazz->getField<JPoint>("MOUTH_RIGHT");
      jni::local_ref<JPoint> MOUTH_RIGHT = this->getFieldValue(fieldMOUTH_RIGHT);
      static const auto fieldNOSE_BASE = clazz->getField<JPoint>("NOSE_BASE");
      jni::local_ref<JPoint> NOSE_BASE = this->getFieldValue(fieldNOSE_BASE);
      static const auto fieldRIGHT_CHEEK = clazz->getField<JPoint>("RIGHT_CHEEK");
      jni::local_ref<JPoint> RIGHT_CHEEK = this->getFieldValue(fieldRIGHT_CHEEK);
      static const auto fieldRIGHT_EAR = clazz->getField<JPoint>("RIGHT_EAR");
      jni::local_ref<JPoint> RIGHT_EAR = this->getFieldValue(fieldRIGHT_EAR);
      static const auto fieldRIGHT_EYE = clazz->getField<JPoint>("RIGHT_EYE");
      jni::local_ref<JPoint> RIGHT_EYE = this->getFieldValue(fieldRIGHT_EYE);
      return Landmarks(
        LEFT_CHEEK != nullptr ? std::make_optional(LEFT_CHEEK->toCpp()) : std::nullopt,
        LEFT_EAR != nullptr ? std::make_optional(LEFT_EAR->toCpp()) : std::nullopt,
        LEFT_EYE != nullptr ? std::make_optional(LEFT_EYE->toCpp()) : std::nullopt,
        MOUTH_BOTTOM != nullptr ? std::make_optional(MOUTH_BOTTOM->toCpp()) : std::nullopt,
        MOUTH_LEFT != nullptr ? std::make_optional(MOUTH_LEFT->toCpp()) : std::nullopt,
        MOUTH_RIGHT != nullptr ? std::make_optional(MOUTH_RIGHT->toCpp()) : std::nullopt,
        NOSE_BASE != nullptr ? std::make_optional(NOSE_BASE->toCpp()) : std::nullopt,
        RIGHT_CHEEK != nullptr ? std::make_optional(RIGHT_CHEEK->toCpp()) : std::nullopt,
        RIGHT_EAR != nullptr ? std::make_optional(RIGHT_EAR->toCpp()) : std::nullopt,
        RIGHT_EYE != nullptr ? std::make_optional(RIGHT_EYE->toCpp()) : 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<JLandmarks::javaobject> fromCpp(const Landmarks& value) {
      using JSignature = JLandmarks(jni::alias_ref<JPoint>, jni::alias_ref<JPoint>, jni::alias_ref<JPoint>, jni::alias_ref<JPoint>, jni::alias_ref<JPoint>, jni::alias_ref<JPoint>, jni::alias_ref<JPoint>, jni::alias_ref<JPoint>, jni::alias_ref<JPoint>, jni::alias_ref<JPoint>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.LEFT_CHEEK.has_value() ? JPoint::fromCpp(value.LEFT_CHEEK.value()) : nullptr,
        value.LEFT_EAR.has_value() ? JPoint::fromCpp(value.LEFT_EAR.value()) : nullptr,
        value.LEFT_EYE.has_value() ? JPoint::fromCpp(value.LEFT_EYE.value()) : nullptr,
        value.MOUTH_BOTTOM.has_value() ? JPoint::fromCpp(value.MOUTH_BOTTOM.value()) : nullptr,
        value.MOUTH_LEFT.has_value() ? JPoint::fromCpp(value.MOUTH_LEFT.value()) : nullptr,
        value.MOUTH_RIGHT.has_value() ? JPoint::fromCpp(value.MOUTH_RIGHT.value()) : nullptr,
        value.NOSE_BASE.has_value() ? JPoint::fromCpp(value.NOSE_BASE.value()) : nullptr,
        value.RIGHT_CHEEK.has_value() ? JPoint::fromCpp(value.RIGHT_CHEEK.value()) : nullptr,
        value.RIGHT_EAR.has_value() ? JPoint::fromCpp(value.RIGHT_EAR.value()) : nullptr,
        value.RIGHT_EYE.has_value() ? JPoint::fromCpp(value.RIGHT_EYE.value()) : nullptr
      );
    }
  };

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