///
/// JAudioInterruptionEvent.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 "AudioInterruptionEvent.hpp"

#include "AudioInterruptionType.hpp"
#include "JAudioInterruptionType.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct AudioInterruptionEvent by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    AudioInterruptionEvent toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldType = clazz->getField<JAudioInterruptionType>("type");
      jni::local_ref<JAudioInterruptionType> type = this->getFieldValue(fieldType);
      static const auto fieldShouldResume = clazz->getField<jboolean>("shouldResume");
      jboolean shouldResume = this->getFieldValue(fieldShouldResume);
      return AudioInterruptionEvent(
        type->toCpp(),
        static_cast<bool>(shouldResume)
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JAudioInterruptionEvent::javaobject> fromCpp(const AudioInterruptionEvent& value) {
      using JSignature = JAudioInterruptionEvent(jni::alias_ref<JAudioInterruptionType>, jboolean);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JAudioInterruptionType::fromCpp(value.type),
        value.shouldResume
      );
    }
  };

} // namespace margelo::nitro::one
