///
/// JFixedDuration.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 "FixedDuration.hpp"

#include "DurationMode.hpp"
#include "JDurationMode.hpp"

namespace margelo::nitro::videopipeline {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct FixedDuration by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    FixedDuration toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldMode = clazz->getField<JDurationMode>("mode");
      jni::local_ref<JDurationMode> mode = this->getFieldValue(fieldMode);
      static const auto fieldSeconds = clazz->getField<double>("seconds");
      double seconds = this->getFieldValue(fieldSeconds);
      return FixedDuration(
        mode->toCpp(),
        seconds
      );
    }

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

} // namespace margelo::nitro::videopipeline
