///
/// JFetchBlobRef.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 "FetchBlobRef.hpp"

#include <string>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct FetchBlobRef by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    FetchBlobRef toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldBlobId = clazz->getField<jni::JString>("blobId");
      jni::local_ref<jni::JString> blobId = this->getFieldValue(fieldBlobId);
      static const auto fieldOffset = clazz->getField<double>("offset");
      double offset = this->getFieldValue(fieldOffset);
      static const auto fieldSize = clazz->getField<double>("size");
      double size = this->getFieldValue(fieldSize);
      return FetchBlobRef(
        blobId->toStdString(),
        offset,
        size
      );
    }

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

} // namespace margelo::nitro::one
