///
/// JVideoTrackSelection.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 "VideoTrackSelection.hpp"

#include "JVideoTrackSelectionType.hpp"
#include "VideoTrackSelectionType.hpp"
#include <optional>

namespace margelo::nitro::aviation {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct VideoTrackSelection by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    VideoTrackSelection toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldType = clazz->getField<JVideoTrackSelectionType>("type");
      jni::local_ref<JVideoTrackSelectionType> type = this->getFieldValue(fieldType);
      static const auto fieldValue = clazz->getField<jni::JDouble>("value");
      jni::local_ref<jni::JDouble> value = this->getFieldValue(fieldValue);
      return VideoTrackSelection(
        type->toCpp(),
        value != nullptr ? std::make_optional(value->value()) : std::nullopt
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JVideoTrackSelection::javaobject> fromCpp(const VideoTrackSelection& value) {
      using JSignature = JVideoTrackSelection(jni::alias_ref<JVideoTrackSelectionType>, jni::alias_ref<jni::JDouble>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JVideoTrackSelectionType::fromCpp(value.type),
        value.value.has_value() ? jni::JDouble::valueOf(value.value.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::aviation
