///
/// JBatteryStateEvent.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 "BatteryStateEvent.hpp"

#include "BatteryState.hpp"
#include "JBatteryState.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct BatteryStateEvent by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    BatteryStateEvent toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldBatteryState = clazz->getField<JBatteryState>("batteryState");
      jni::local_ref<JBatteryState> batteryState = this->getFieldValue(fieldBatteryState);
      return BatteryStateEvent(
        batteryState->toCpp()
      );
    }

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

} // namespace margelo::nitro::one
