///
/// JHingeState.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 "HingeState.hpp"

#include "HingeStatus.hpp"
#include "JHingeStatus.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct HingeState by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    HingeState toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldStatus = clazz->getField<JHingeStatus>("status");
      jni::local_ref<JHingeStatus> status = this->getFieldValue(fieldStatus);
      static const auto fieldAngle = clazz->getField<double>("angle");
      double angle = this->getFieldValue(fieldAngle);
      return HingeState(
        status->toCpp(),
        angle
      );
    }

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

} // namespace margelo::nitro::one
