///
/// JSubscriptionProductReplacementParamsAndroid.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 "SubscriptionProductReplacementParamsAndroid.hpp"

#include "JSubscriptionReplacementModeAndroid.hpp"
#include "SubscriptionReplacementModeAndroid.hpp"
#include <string>

namespace margelo::nitro::iap {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct SubscriptionProductReplacementParamsAndroid by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    SubscriptionProductReplacementParamsAndroid toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldOldProductId = clazz->getField<jni::JString>("oldProductId");
      jni::local_ref<jni::JString> oldProductId = this->getFieldValue(fieldOldProductId);
      static const auto fieldReplacementMode = clazz->getField<JSubscriptionReplacementModeAndroid>("replacementMode");
      jni::local_ref<JSubscriptionReplacementModeAndroid> replacementMode = this->getFieldValue(fieldReplacementMode);
      return SubscriptionProductReplacementParamsAndroid(
        oldProductId->toStdString(),
        replacementMode->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<JSubscriptionProductReplacementParamsAndroid::javaobject> fromCpp(const SubscriptionProductReplacementParamsAndroid& value) {
      using JSignature = JSubscriptionProductReplacementParamsAndroid(jni::alias_ref<jni::JString>, jni::alias_ref<JSubscriptionReplacementModeAndroid>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        jni::make_jstring(value.oldProductId),
        JSubscriptionReplacementModeAndroid::fromCpp(value.replacementMode)
      );
    }
  };

} // namespace margelo::nitro::iap
