///
/// JBackgroundTaskInvocation.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 "BackgroundTaskInvocation.hpp"

#include "BackgroundTaskKind.hpp"
#include "JBackgroundTaskKind.hpp"
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct BackgroundTaskInvocation by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    BackgroundTaskInvocation toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldExecutionId = clazz->getField<jni::JString>("executionId");
      jni::local_ref<jni::JString> executionId = this->getFieldValue(fieldExecutionId);
      static const auto fieldIdentifier = clazz->getField<jni::JString>("identifier");
      jni::local_ref<jni::JString> identifier = this->getFieldValue(fieldIdentifier);
      static const auto fieldKind = clazz->getField<JBackgroundTaskKind>("kind");
      jni::local_ref<JBackgroundTaskKind> kind = this->getFieldValue(fieldKind);
      return BackgroundTaskInvocation(
        executionId->toStdString(),
        identifier->toStdString(),
        kind->toCpp()
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JBackgroundTaskInvocation::javaobject> fromCpp(const BackgroundTaskInvocation& value) {
      using JSignature = JBackgroundTaskInvocation(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<JBackgroundTaskKind>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.executionId),
        jni::make_jstring(value.identifier),
        JBackgroundTaskKind::fromCpp(value.kind)
      );
    }
  };

} // namespace margelo::nitro::one
