///
/// JonLoadStartData.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 "onLoadStartData.hpp"

#include "HybridVideoPlayerSourceSpec.hpp"
#include "JHybridVideoPlayerSourceSpec.hpp"
#include "JSourceType.hpp"
#include "SourceType.hpp"
#include <memory>

namespace margelo::nitro::video {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct onLoadStartData by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    onLoadStartData toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldSourceType = clazz->getField<JSourceType>("sourceType");
      jni::local_ref<JSourceType> sourceType = this->getFieldValue(fieldSourceType);
      static const auto fieldSource = clazz->getField<JHybridVideoPlayerSourceSpec::javaobject>("source");
      jni::local_ref<JHybridVideoPlayerSourceSpec::javaobject> source = this->getFieldValue(fieldSource);
      return onLoadStartData(
        sourceType->toCpp(),
        source->cthis()->shared_cast<JHybridVideoPlayerSourceSpec>()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JonLoadStartData::javaobject> fromCpp(const onLoadStartData& value) {
      return newInstance(
        JSourceType::fromCpp(value.sourceType),
        std::dynamic_pointer_cast<JHybridVideoPlayerSourceSpec>(value.source)->getJavaPart()
      );
    }
  };

} // namespace margelo::nitro::video
