///
/// JCastOptions.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 "CastOptions.hpp"

#include <optional>
#include <string>

namespace margelo::nitro::omni {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct CastOptions by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    CastOptions toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldReceiverApplicationId = clazz->getField<jni::JString>("receiverApplicationId");
      jni::local_ref<jni::JString> receiverApplicationId = this->getFieldValue(fieldReceiverApplicationId);
      static const auto fieldNotificationUrl = clazz->getField<jni::JString>("notificationUrl");
      jni::local_ref<jni::JString> notificationUrl = this->getFieldValue(fieldNotificationUrl);
      return CastOptions(
        receiverApplicationId != nullptr ? std::make_optional(receiverApplicationId->toStdString()) : std::nullopt,
        notificationUrl != nullptr ? std::make_optional(notificationUrl->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<JCastOptions::javaobject> fromCpp(const CastOptions& value) {
      using JSignature = JCastOptions(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.receiverApplicationId.has_value() ? jni::make_jstring(value.receiverApplicationId.value()) : nullptr,
        value.notificationUrl.has_value() ? jni::make_jstring(value.notificationUrl.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::omni
