///
/// JMediaPosition.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 "MediaPosition.hpp"



namespace margelo::nitro::aviation {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct MediaPosition by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    MediaPosition toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldCurrentMs = clazz->getField<double>("currentMs");
      double currentMs = this->getFieldValue(fieldCurrentMs);
      static const auto fieldDurationMs = clazz->getField<double>("durationMs");
      double durationMs = this->getFieldValue(fieldDurationMs);
      static const auto fieldSeekableStartMs = clazz->getField<double>("seekableStartMs");
      double seekableStartMs = this->getFieldValue(fieldSeekableStartMs);
      static const auto fieldSeekableEndMs = clazz->getField<double>("seekableEndMs");
      double seekableEndMs = this->getFieldValue(fieldSeekableEndMs);
      static const auto fieldIsLive = clazz->getField<jboolean>("isLive");
      jboolean isLive = this->getFieldValue(fieldIsLive);
      static const auto fieldProgress = clazz->getField<double>("progress");
      double progress = this->getFieldValue(fieldProgress);
      static const auto fieldLiveEdgeOffsetMs = clazz->getField<double>("liveEdgeOffsetMs");
      double liveEdgeOffsetMs = this->getFieldValue(fieldLiveEdgeOffsetMs);
      static const auto fieldIsAtLiveEdge = clazz->getField<jboolean>("isAtLiveEdge");
      jboolean isAtLiveEdge = this->getFieldValue(fieldIsAtLiveEdge);
      return MediaPosition(
        currentMs,
        durationMs,
        seekableStartMs,
        seekableEndMs,
        static_cast<bool>(isLive),
        progress,
        liveEdgeOffsetMs,
        static_cast<bool>(isAtLiveEdge)
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JMediaPosition::javaobject> fromCpp(const MediaPosition& value) {
      using JSignature = JMediaPosition(double, double, double, double, jboolean, double, double, jboolean);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.currentMs,
        value.durationMs,
        value.seekableStartMs,
        value.seekableEndMs,
        value.isLive,
        value.progress,
        value.liveEdgeOffsetMs,
        value.isAtLiveEdge
      );
    }
  };

} // namespace margelo::nitro::aviation
