///
/// JNativeNotificationCategory.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 "NativeNotificationCategory.hpp"

#include "JNativeNotificationAction.hpp"
#include "JNativeNotificationCategoryOptions.hpp"
#include "NativeNotificationAction.hpp"
#include "NativeNotificationCategoryOptions.hpp"
#include <optional>
#include <string>
#include <vector>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeNotificationCategory by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeNotificationCategory toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldIdentifier = clazz->getField<jni::JString>("identifier");
      jni::local_ref<jni::JString> identifier = this->getFieldValue(fieldIdentifier);
      static const auto fieldActions = clazz->getField<jni::JArrayClass<JNativeNotificationAction>>("actions");
      jni::local_ref<jni::JArrayClass<JNativeNotificationAction>> actions = this->getFieldValue(fieldActions);
      static const auto fieldOptions = clazz->getField<JNativeNotificationCategoryOptions>("options");
      jni::local_ref<JNativeNotificationCategoryOptions> options = this->getFieldValue(fieldOptions);
      return NativeNotificationCategory(
        identifier->toStdString(),
        [&](auto&& __input) {
          size_t __size = __input->size();
          std::vector<NativeNotificationAction> __vector;
          __vector.reserve(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            auto __element = __input->getElement(__i);
            __vector.push_back(__element->toCpp());
          }
          return __vector;
        }(actions),
        options != nullptr ? std::make_optional(options->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<JNativeNotificationCategory::javaobject> fromCpp(const NativeNotificationCategory& value) {
      using JSignature = JNativeNotificationCategory(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<JNativeNotificationAction>>, jni::alias_ref<JNativeNotificationCategoryOptions>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.identifier),
        [&](auto&& __input) {
          size_t __size = __input.size();
          jni::local_ref<jni::JArrayClass<JNativeNotificationAction>> __array = jni::JArrayClass<JNativeNotificationAction>::newArray(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            const auto& __element = __input[__i];
            auto __elementJni = JNativeNotificationAction::fromCpp(__element);
            __array->setElement(__i, *__elementJni);
          }
          return __array;
        }(value.actions),
        value.options.has_value() ? JNativeNotificationCategoryOptions::fromCpp(value.options.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
