///
/// JNitroDiscountDisplayInfoAndroid.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 "NitroDiscountDisplayInfoAndroid.hpp"

#include "JNitroDiscountAmountAndroid.hpp"
#include "JVariant_NullType_Double.hpp"
#include "JVariant_NullType_NitroDiscountAmountAndroid.hpp"
#include "NitroDiscountAmountAndroid.hpp"
#include <NitroModules/JNull.hpp>
#include <NitroModules/Null.hpp>
#include <optional>
#include <string>
#include <variant>

namespace margelo::nitro::iap {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NitroDiscountDisplayInfoAndroid by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NitroDiscountDisplayInfoAndroid toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldDiscountAmount = clazz->getField<JVariant_NullType_NitroDiscountAmountAndroid>("discountAmount");
      jni::local_ref<JVariant_NullType_NitroDiscountAmountAndroid> discountAmount = this->getFieldValue(fieldDiscountAmount);
      static const auto fieldPercentageDiscount = clazz->getField<JVariant_NullType_Double>("percentageDiscount");
      jni::local_ref<JVariant_NullType_Double> percentageDiscount = this->getFieldValue(fieldPercentageDiscount);
      return NitroDiscountDisplayInfoAndroid(
        discountAmount != nullptr ? std::make_optional(discountAmount->toCpp()) : std::nullopt,
        percentageDiscount != nullptr ? std::make_optional(percentageDiscount->toCpp()) : std::nullopt
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JNitroDiscountDisplayInfoAndroid::javaobject> fromCpp(const NitroDiscountDisplayInfoAndroid& value) {
      using JSignature = JNitroDiscountDisplayInfoAndroid(jni::alias_ref<JVariant_NullType_NitroDiscountAmountAndroid>, jni::alias_ref<JVariant_NullType_Double>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.discountAmount.has_value() ? JVariant_NullType_NitroDiscountAmountAndroid::fromCpp(value.discountAmount.value()) : nullptr,
        value.percentageDiscount.has_value() ? JVariant_NullType_Double::fromCpp(value.percentageDiscount.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::iap
