///
/// JMotionSensor.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 "MotionSensor.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based enum to the C++ enum MotionSensor.
     */
    [[maybe_unused]]
    [[nodiscard]]
    MotionSensor toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldOrdinal = clazz->getField<int>("value");
      int ordinal = this->getFieldValue(fieldOrdinal);
      return static_cast<MotionSensor>(ordinal);
    }

  public:
    /**
     * Create a Java/Kotlin-based enum with the given C++ enum's value.
     */
    [[maybe_unused]]
    static jni::alias_ref<JMotionSensor> fromCpp(MotionSensor value) {
      static const auto clazz = javaClassStatic();
      switch (value) {
        case MotionSensor::ACCELEROMETER:
          static const auto fieldACCELEROMETER = clazz->getStaticField<JMotionSensor>("ACCELEROMETER");
          return clazz->getStaticFieldValue(fieldACCELEROMETER);
        case MotionSensor::GYROSCOPE:
          static const auto fieldGYROSCOPE = clazz->getStaticField<JMotionSensor>("GYROSCOPE");
          return clazz->getStaticFieldValue(fieldGYROSCOPE);
        case MotionSensor::MAGNETOMETER:
          static const auto fieldMAGNETOMETER = clazz->getStaticField<JMotionSensor>("MAGNETOMETER");
          return clazz->getStaticFieldValue(fieldMAGNETOMETER);
        case MotionSensor::DEVICEMOTION:
          static const auto fieldDEVICEMOTION = clazz->getStaticField<JMotionSensor>("DEVICEMOTION");
          return clazz->getStaticFieldValue(fieldDEVICEMOTION);
        default:
          std::string stringValue = std::to_string(static_cast<int>(value));
          throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
      }
    }
  };

} // namespace margelo::nitro::one
