///
/// JImageOverlaySize.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 "ImageOverlaySize.hpp"

#include "Dim.hpp"
#include "JDim.hpp"
#include "JSizeUnit.hpp"
#include "SizeUnit.hpp"
#include <optional>

namespace margelo::nitro::videopipeline {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct ImageOverlaySize by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    ImageOverlaySize toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldW = clazz->getField<JDim>("w");
      jni::local_ref<JDim> w = this->getFieldValue(fieldW);
      static const auto fieldH = clazz->getField<JDim>("h");
      jni::local_ref<JDim> h = this->getFieldValue(fieldH);
      return ImageOverlaySize(
        w != nullptr ? std::make_optional(w->toCpp()) : std::nullopt,
        h != nullptr ? std::make_optional(h->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<JImageOverlaySize::javaobject> fromCpp(const ImageOverlaySize& value) {
      using JSignature = JImageOverlaySize(jni::alias_ref<JDim>, jni::alias_ref<JDim>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.w.has_value() ? JDim::fromCpp(value.w.value()) : nullptr,
        value.h.has_value() ? JDim::fromCpp(value.h.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::videopipeline
