///
/// JNativeScheduleInput.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 "NativeScheduleInput.hpp"

#include "JNativeContentInput.hpp"
#include "JNativeTriggerInput.hpp"
#include "NativeContentInput.hpp"
#include "NativeTriggerInput.hpp"
#include <NitroModules/AnyMap.hpp>
#include <NitroModules/JAnyMap.hpp>
#include <optional>
#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct NativeScheduleInput by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    NativeScheduleInput toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldIdentifier = clazz->getField<jni::JString>("identifier");
      jni::local_ref<jni::JString> identifier = this->getFieldValue(fieldIdentifier);
      static const auto fieldContent = clazz->getField<JNativeContentInput>("content");
      jni::local_ref<JNativeContentInput> content = this->getFieldValue(fieldContent);
      static const auto fieldTrigger = clazz->getField<JNativeTriggerInput>("trigger");
      jni::local_ref<JNativeTriggerInput> trigger = this->getFieldValue(fieldTrigger);
      return NativeScheduleInput(
        identifier != nullptr ? std::make_optional(identifier->toStdString()) : std::nullopt,
        content->toCpp(),
        trigger != nullptr ? std::make_optional(trigger->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<JNativeScheduleInput::javaobject> fromCpp(const NativeScheduleInput& value) {
      using JSignature = JNativeScheduleInput(jni::alias_ref<jni::JString>, jni::alias_ref<JNativeContentInput>, jni::alias_ref<JNativeTriggerInput>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        value.identifier.has_value() ? jni::make_jstring(value.identifier.value()) : nullptr,
        JNativeContentInput::fromCpp(value.content),
        value.trigger.has_value() ? JNativeTriggerInput::fromCpp(value.trigger.value()) : nullptr
      );
    }
  };

} // namespace margelo::nitro::one
