///
/// JServiceDataEntry.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 "ServiceDataEntry.hpp"

#include <string>

namespace margelo::nitro::munimbluetooth {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct ServiceDataEntry by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    ServiceDataEntry toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldUuid = clazz->getField<jni::JString>("uuid");
      jni::local_ref<jni::JString> uuid = this->getFieldValue(fieldUuid);
      static const auto fieldData = clazz->getField<jni::JString>("data");
      jni::local_ref<jni::JString> data = this->getFieldValue(fieldData);
      return ServiceDataEntry(
        uuid->toStdString(),
        data->toStdString()
      );
    }

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

} // namespace margelo::nitro::munimbluetooth
