///
/// JTextOverlay.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 "TextOverlay.hpp"

#include "AnchorPoint.hpp"
#include "FontWeight.hpp"
#include "JAnchorPoint.hpp"
#include "JFontWeight.hpp"
#include "JOverlayKind.hpp"
#include "JTextAlign.hpp"
#include "JTextShadow.hpp"
#include "JTextStyle.hpp"
#include "JTimeRange.hpp"
#include "OverlayKind.hpp"
#include "TextAlign.hpp"
#include "TextShadow.hpp"
#include "TextStyle.hpp"
#include "TimeRange.hpp"
#include <optional>
#include <string>

namespace margelo::nitro::videopipeline {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct TextOverlay by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    TextOverlay toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldKind = clazz->getField<JOverlayKind>("kind");
      jni::local_ref<JOverlayKind> kind = this->getFieldValue(fieldKind);
      static const auto fieldText = clazz->getField<jni::JString>("text");
      jni::local_ref<jni::JString> text = this->getFieldValue(fieldText);
      static const auto fieldStyle = clazz->getField<JTextStyle>("style");
      jni::local_ref<JTextStyle> style = this->getFieldValue(fieldStyle);
      static const auto fieldAnchor = clazz->getField<JAnchorPoint>("anchor");
      jni::local_ref<JAnchorPoint> anchor = this->getFieldValue(fieldAnchor);
      static const auto fieldTimeRange = clazz->getField<JTimeRange>("timeRange");
      jni::local_ref<JTimeRange> timeRange = this->getFieldValue(fieldTimeRange);
      return TextOverlay(
        kind->toCpp(),
        text->toStdString(),
        style->toCpp(),
        anchor->toCpp(),
        timeRange != nullptr ? std::make_optional(timeRange->toCpp()) : 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<JTextOverlay::javaobject> fromCpp(const TextOverlay& value) {
      using JSignature = JTextOverlay(jni::alias_ref<JOverlayKind>, jni::alias_ref<jni::JString>, jni::alias_ref<JTextStyle>, jni::alias_ref<JAnchorPoint>, jni::alias_ref<JTimeRange>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JOverlayKind::fromCpp(value.kind),
        jni::make_jstring(value.text),
        JTextStyle::fromCpp(value.style),
        JAnchorPoint::fromCpp(value.anchor),
        value.timeRange.has_value() ? JTimeRange::fromCpp(value.timeRange.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::videopipeline
