///
/// JMapPlace.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 "MapPlace.hpp"

#include "JMapCoordinate.hpp"
#include "MapCoordinate.hpp"
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct MapPlace by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    MapPlace toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldName = clazz->getField<jni::JString>("name");
      jni::local_ref<jni::JString> name = this->getFieldValue(fieldName);
      static const auto fieldAddress = clazz->getField<jni::JString>("address");
      jni::local_ref<jni::JString> address = this->getFieldValue(fieldAddress);
      static const auto fieldCoordinate = clazz->getField<JMapCoordinate>("coordinate");
      jni::local_ref<JMapCoordinate> coordinate = this->getFieldValue(fieldCoordinate);
      return MapPlace(
        name->toStdString(),
        address->toStdString(),
        coordinate->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<JMapPlace::javaobject> fromCpp(const MapPlace& value) {
      using JSignature = JMapPlace(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<JMapCoordinate>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.name),
        jni::make_jstring(value.address),
        JMapCoordinate::fromCpp(value.coordinate)
      );
    }
  };

} // namespace margelo::nitro::one
