///
/// JVariant_CustomError_PaymentResult.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 <variant>

#include "CustomError.hpp"
#include "PaymentResult.hpp"
#include <variant>
#include "JCustomError.hpp"
#include "ErrorCode.hpp"
#include "JErrorCode.hpp"
#include <string>
#include "JPaymentResult.hpp"
#include "PaymentTypes.hpp"
#include "JPaymentTypes.hpp"
#include "InstallmentTypes.hpp"
#include "JInstallmentTypes.hpp"

namespace margelo::nitro::taponpagseguro {

  using namespace facebook;

  /**
   * The C++ JNI bridge between the C++ std::variant and the Java class "Variant_CustomError_PaymentResult".
   */
  class JVariant_CustomError_PaymentResult: public jni::JavaClass<JVariant_CustomError_PaymentResult> {
  public:
    static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/taponpagseguro/Variant_CustomError_PaymentResult;";

    static jni::local_ref<JVariant_CustomError_PaymentResult> create_0(jni::alias_ref<JCustomError> value) {
      static const auto method = javaClassStatic()->getStaticMethod<JVariant_CustomError_PaymentResult(jni::alias_ref<JCustomError>)>("create");
      return method(javaClassStatic(), value);
    }
    static jni::local_ref<JVariant_CustomError_PaymentResult> create_1(jni::alias_ref<JPaymentResult> value) {
      static const auto method = javaClassStatic()->getStaticMethod<JVariant_CustomError_PaymentResult(jni::alias_ref<JPaymentResult>)>("create");
      return method(javaClassStatic(), value);
    }

    static jni::local_ref<JVariant_CustomError_PaymentResult> fromCpp(const std::variant<CustomError, PaymentResult>& variant) {
      switch (variant.index()) {
        case 0: return create_0(JCustomError::fromCpp(std::get<0>(variant)));
        case 1: return create_1(JPaymentResult::fromCpp(std::get<1>(variant)));
        default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
      }
    }

    [[nodiscard]] std::variant<CustomError, PaymentResult> toCpp() const;
  };

  namespace JVariant_CustomError_PaymentResult_impl {
    class First final: public jni::JavaClass<First, JVariant_CustomError_PaymentResult> {
    public:
      static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/taponpagseguro/Variant_CustomError_PaymentResult$First;";
    
      [[nodiscard]] jni::local_ref<JCustomError> getValue() const {
        static const auto field = javaClassStatic()->getField<JCustomError>("value");
        return getFieldValue(field);
      }
    };
    
    class Second final: public jni::JavaClass<Second, JVariant_CustomError_PaymentResult> {
    public:
      static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/taponpagseguro/Variant_CustomError_PaymentResult$Second;";
    
      [[nodiscard]] jni::local_ref<JPaymentResult> getValue() const {
        static const auto field = javaClassStatic()->getField<JPaymentResult>("value");
        return getFieldValue(field);
      }
    };
  } // namespace JVariant_CustomError_PaymentResult_impl
} // namespace margelo::nitro::taponpagseguro
