///
/// JMotionAvailability.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 "MotionAvailability.hpp"



namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct MotionAvailability by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    MotionAvailability toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldAccelerometer = clazz->getField<jboolean>("accelerometer");
      jboolean accelerometer = this->getFieldValue(fieldAccelerometer);
      static const auto fieldGyroscope = clazz->getField<jboolean>("gyroscope");
      jboolean gyroscope = this->getFieldValue(fieldGyroscope);
      static const auto fieldMagnetometer = clazz->getField<jboolean>("magnetometer");
      jboolean magnetometer = this->getFieldValue(fieldMagnetometer);
      static const auto fieldDeviceMotion = clazz->getField<jboolean>("deviceMotion");
      jboolean deviceMotion = this->getFieldValue(fieldDeviceMotion);
      return MotionAvailability(
        static_cast<bool>(accelerometer),
        static_cast<bool>(gyroscope),
        static_cast<bool>(magnetometer),
        static_cast<bool>(deviceMotion)
      );
    }

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

} // namespace margelo::nitro::one
