///
/// JDecorationActivatedEvent.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 "DecorationActivatedEvent.hpp"

#include "Decoration.hpp"
#include "DecorationStyle.hpp"
#include "JDecoration.hpp"
#include "JDecorationStyle.hpp"
#include "JLocator.hpp"
#include "JLocatorLocations.hpp"
#include "JLocatorText.hpp"
#include "JPoint.hpp"
#include "JRect.hpp"
#include "Locator.hpp"
#include "LocatorLocations.hpp"
#include "LocatorText.hpp"
#include "Point.hpp"
#include "Rect.hpp"
#include <optional>
#include <string>
#include <unordered_map>

namespace margelo::nitro::readium {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct DecorationActivatedEvent by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    DecorationActivatedEvent toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldDecoration = clazz->getField<JDecoration>("decoration");
      jni::local_ref<JDecoration> decoration = this->getFieldValue(fieldDecoration);
      static const auto fieldGroup = clazz->getField<jni::JString>("group");
      jni::local_ref<jni::JString> group = this->getFieldValue(fieldGroup);
      static const auto fieldRect = clazz->getField<JRect>("rect");
      jni::local_ref<JRect> rect = this->getFieldValue(fieldRect);
      static const auto fieldPoint = clazz->getField<JPoint>("point");
      jni::local_ref<JPoint> point = this->getFieldValue(fieldPoint);
      return DecorationActivatedEvent(
        decoration->toCpp(),
        group->toStdString(),
        rect != nullptr ? std::make_optional(rect->toCpp()) : std::nullopt,
        point != nullptr ? std::make_optional(point->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<JDecorationActivatedEvent::javaobject> fromCpp(const DecorationActivatedEvent& value) {
      using JSignature = JDecorationActivatedEvent(jni::alias_ref<JDecoration>, jni::alias_ref<jni::JString>, jni::alias_ref<JRect>, jni::alias_ref<JPoint>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JDecoration::fromCpp(value.decoration),
        jni::make_jstring(value.group),
        value.rect.has_value() ? JRect::fromCpp(value.rect.value()) : nullptr,
        value.point.has_value() ? JPoint::fromCpp(value.point.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::readium
