///
/// JPhotoLibraryAlbumPage.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 "PhotoLibraryAlbumPage.hpp"

#include "JPhotoLibraryAlbum.hpp"
#include "PhotoLibraryAlbum.hpp"
#include <string>
#include <vector>

namespace margelo::nitro::one {

  using namespace facebook;

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

  public:
    /**
     * Convert this Java/Kotlin-based struct to the C++ struct PhotoLibraryAlbumPage by copying all values to C++.
     */
    [[maybe_unused]]
    [[nodiscard]]
    PhotoLibraryAlbumPage toCpp() const {
      static const auto clazz = javaClassStatic();
      static const auto fieldAlbums = clazz->getField<jni::JArrayClass<JPhotoLibraryAlbum>>("albums");
      jni::local_ref<jni::JArrayClass<JPhotoLibraryAlbum>> albums = this->getFieldValue(fieldAlbums);
      static const auto fieldTotalCount = clazz->getField<double>("totalCount");
      double totalCount = this->getFieldValue(fieldTotalCount);
      return PhotoLibraryAlbumPage(
        [&](auto&& __input) {
          size_t __size = __input->size();
          std::vector<PhotoLibraryAlbum> __vector;
          __vector.reserve(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            auto __element = __input->getElement(__i);
            __vector.push_back(__element->toCpp());
          }
          return __vector;
        }(albums),
        totalCount
      );
    }

  public:
    /**
     * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
     */
    [[maybe_unused]]
    static jni::local_ref<JPhotoLibraryAlbumPage::javaobject> fromCpp(const PhotoLibraryAlbumPage& value) {
      using JSignature = JPhotoLibraryAlbumPage(jni::alias_ref<jni::JArrayClass<JPhotoLibraryAlbum>>, double);
      static const auto clazz = javaClassStatic();
      static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
      return create(
        clazz,
        [&](auto&& __input) {
          size_t __size = __input.size();
          jni::local_ref<jni::JArrayClass<JPhotoLibraryAlbum>> __array = jni::JArrayClass<JPhotoLibraryAlbum>::newArray(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            const auto& __element = __input[__i];
            auto __elementJni = JPhotoLibraryAlbum::fromCpp(__element);
            __array->setElement(__i, *__elementJni);
          }
          return __array;
        }(value.albums),
        value.totalCount
      );
    }
  };

} // namespace margelo::nitro::one
