///
/// JBrightnessPermissionResponse.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 "BrightnessPermissionResponse.hpp"

#include "BrightnessPermissionStatus.hpp"
#include "JBrightnessPermissionStatus.hpp"

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct BrightnessPermissionResponse by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    BrightnessPermissionResponse toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldStatus = clazz->getField<JBrightnessPermissionStatus>("status");
      jni::local_ref<JBrightnessPermissionStatus> status = this->getFieldValue(fieldStatus);
      static const auto fieldGranted = clazz->getField<jboolean>("granted");
      jboolean granted = this->getFieldValue(fieldGranted);
      static const auto fieldCanAskAgain = clazz->getField<jboolean>("canAskAgain");
      jboolean canAskAgain = this->getFieldValue(fieldCanAskAgain);
      return BrightnessPermissionResponse(
        status->toCpp(),
        static_cast<bool>(granted),
        static_cast<bool>(canAskAgain)
      );
    }

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

} // namespace margelo::nitro::one
