///
/// JonLoadData.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include "onLoadData.hpp"

#include "JVideoOrientation.hpp"
#include "VideoOrientation.hpp"

namespace margelo::nitro::video {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct onLoadData by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    onLoadData toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldCurrentTime = clazz->getField<double>("currentTime");
      double currentTime = this->getFieldValue(fieldCurrentTime);
      static const auto fieldDuration = clazz->getField<double>("duration");
      double duration = this->getFieldValue(fieldDuration);
      static const auto fieldHeight = clazz->getField<double>("height");
      double height = this->getFieldValue(fieldHeight);
      static const auto fieldWidth = clazz->getField<double>("width");
      double width = this->getFieldValue(fieldWidth);
      static const auto fieldOrientation = clazz->getField<JVideoOrientation>("orientation");
      jni::local_ref<JVideoOrientation> orientation = this->getFieldValue(fieldOrientation);
      return onLoadData(
        currentTime,
        duration,
        height,
        width,
        orientation->toCpp()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JonLoadData::javaobject> fromCpp(const onLoadData& value) {
      return newInstance(
        value.currentTime,
        value.duration,
        value.height,
        value.width,
        JVideoOrientation::fromCpp(value.orientation)
      );
    }
  };

} // namespace margelo::nitro::video
