///
/// JContactPostalAddressInput.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 "ContactPostalAddressInput.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct ContactPostalAddressInput by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    ContactPostalAddressInput toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldLabel = clazz->getField<jni::JString>("label");
      jni::local_ref<jni::JString> label = this->getFieldValue(fieldLabel);
      static const auto fieldStreet = clazz->getField<jni::JString>("street");
      jni::local_ref<jni::JString> street = this->getFieldValue(fieldStreet);
      static const auto fieldSubLocality = clazz->getField<jni::JString>("subLocality");
      jni::local_ref<jni::JString> subLocality = this->getFieldValue(fieldSubLocality);
      static const auto fieldCity = clazz->getField<jni::JString>("city");
      jni::local_ref<jni::JString> city = this->getFieldValue(fieldCity);
      static const auto fieldSubAdministrativeArea = clazz->getField<jni::JString>("subAdministrativeArea");
      jni::local_ref<jni::JString> subAdministrativeArea = this->getFieldValue(fieldSubAdministrativeArea);
      static const auto fieldState = clazz->getField<jni::JString>("state");
      jni::local_ref<jni::JString> state = this->getFieldValue(fieldState);
      static const auto fieldPostalCode = clazz->getField<jni::JString>("postalCode");
      jni::local_ref<jni::JString> postalCode = this->getFieldValue(fieldPostalCode);
      static const auto fieldCountry = clazz->getField<jni::JString>("country");
      jni::local_ref<jni::JString> country = this->getFieldValue(fieldCountry);
      static const auto fieldIsoCountryCode = clazz->getField<jni::JString>("isoCountryCode");
      jni::local_ref<jni::JString> isoCountryCode = this->getFieldValue(fieldIsoCountryCode);
      return ContactPostalAddressInput(
        label != nullptr ? std::make_optional(label->toStdString()) : std::nullopt,
        street != nullptr ? std::make_optional(street->toStdString()) : std::nullopt,
        subLocality != nullptr ? std::make_optional(subLocality->toStdString()) : std::nullopt,
        city != nullptr ? std::make_optional(city->toStdString()) : std::nullopt,
        subAdministrativeArea != nullptr ? std::make_optional(subAdministrativeArea->toStdString()) : std::nullopt,
        state != nullptr ? std::make_optional(state->toStdString()) : std::nullopt,
        postalCode != nullptr ? std::make_optional(postalCode->toStdString()) : std::nullopt,
        country != nullptr ? std::make_optional(country->toStdString()) : std::nullopt,
        isoCountryCode != nullptr ? std::make_optional(isoCountryCode->toStdString()) : 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<JContactPostalAddressInput::javaobject> fromCpp(const ContactPostalAddressInput& value) {
      using JSignature = JContactPostalAddressInput(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.label.has_value() ? jni::make_jstring(value.label.value()) : nullptr,
        value.street.has_value() ? jni::make_jstring(value.street.value()) : nullptr,
        value.subLocality.has_value() ? jni::make_jstring(value.subLocality.value()) : nullptr,
        value.city.has_value() ? jni::make_jstring(value.city.value()) : nullptr,
        value.subAdministrativeArea.has_value() ? jni::make_jstring(value.subAdministrativeArea.value()) : nullptr,
        value.state.has_value() ? jni::make_jstring(value.state.value()) : nullptr,
        value.postalCode.has_value() ? jni::make_jstring(value.postalCode.value()) : nullptr,
        value.country.has_value() ? jni::make_jstring(value.country.value()) : nullptr,
        value.isoCountryCode.has_value() ? jni::make_jstring(value.isoCountryCode.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
