///
/// JDynamicRange.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 "DynamicRange.hpp"

#include "ColorRange.hpp"
#include "ColorSpace.hpp"
#include "DynamicRangeBitDepth.hpp"
#include "JColorRange.hpp"
#include "JColorSpace.hpp"
#include "JDynamicRangeBitDepth.hpp"

namespace margelo::nitro::camera {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct DynamicRange by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    DynamicRange toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldBitDepth = clazz->getField<JDynamicRangeBitDepth>("bitDepth");
      jni::local_ref<JDynamicRangeBitDepth> bitDepth = this->getFieldValue(fieldBitDepth);
      static const auto fieldColorSpace = clazz->getField<JColorSpace>("colorSpace");
      jni::local_ref<JColorSpace> colorSpace = this->getFieldValue(fieldColorSpace);
      static const auto fieldColorRange = clazz->getField<JColorRange>("colorRange");
      jni::local_ref<JColorRange> colorRange = this->getFieldValue(fieldColorRange);
      return DynamicRange(
        bitDepth->toCpp(),
        colorSpace->toCpp(),
        colorRange->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<JDynamicRange::javaobject> fromCpp(const DynamicRange& value) {
      using JSignature = JDynamicRange(jni::alias_ref<JDynamicRangeBitDepth>, jni::alias_ref<JColorSpace>, jni::alias_ref<JColorRange>);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        JDynamicRangeBitDepth::fromCpp(value.bitDepth),
        JColorSpace::fromCpp(value.colorSpace),
        JColorRange::fromCpp(value.colorRange)
      );
    }
  };

} // namespace margelo::nitro::camera
