///
/// JMapRouteStep.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 "MapRouteStep.hpp"

#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

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

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

} // namespace margelo::nitro::one
