///
/// JDim.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 "Dim.hpp"

#include "JSizeUnit.hpp"
#include "SizeUnit.hpp"

namespace margelo::nitro::videopipeline {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct Dim by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    Dim toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldUnit = clazz->getField<JSizeUnit>("unit");
      jni::local_ref<JSizeUnit> unit = this->getFieldValue(fieldUnit);
      static const auto fieldValue = clazz->getField<double>("value");
      double value = this->getFieldValue(fieldValue);
      return Dim(
        unit->toCpp(),
        value
      );
    }

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

} // namespace margelo::nitro::videopipeline
