///
/// JRect.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 "Rect.hpp"



namespace margelo::nitro::camera::barcodescanner {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct Rect by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    Rect toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldLeft = clazz->getField<double>("left");
      double left = this->getFieldValue(fieldLeft);
      static const auto fieldRight = clazz->getField<double>("right");
      double right = this->getFieldValue(fieldRight);
      static const auto fieldTop = clazz->getField<double>("top");
      double top = this->getFieldValue(fieldTop);
      static const auto fieldBottom = clazz->getField<double>("bottom");
      double bottom = this->getFieldValue(fieldBottom);
      return Rect(
        left,
        right,
        top,
        bottom
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JRect::javaobject> fromCpp(const Rect& value) {
      using JSignature = JRect(double, double, double, double);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.left,
        value.right,
        value.top,
        value.bottom
      );
    }
  };

} // namespace margelo::nitro::camera::barcodescanner
