///
/// JHybridGoogleSignInButtonSpec.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#include "JHybridGoogleSignInButtonSpec.hpp"

// Forward declaration of `GoogleSignInButtonColorScheme` to properly resolve imports.
namespace margelo::nitro::nitrogooglesignin { enum class GoogleSignInButtonColorScheme; }
// Forward declaration of `GoogleSignInButtonNativeSize` to properly resolve imports.
namespace margelo::nitro::nitrogooglesignin { enum class GoogleSignInButtonNativeSize; }
// Forward declaration of `GoogleSignInButtonContentAlignment` to properly resolve imports.
namespace margelo::nitro::nitrogooglesignin { enum class GoogleSignInButtonContentAlignment; }

#include "GoogleSignInButtonColorScheme.hpp"
#include "JGoogleSignInButtonColorScheme.hpp"
#include "GoogleSignInButtonNativeSize.hpp"
#include "JGoogleSignInButtonNativeSize.hpp"
#include "GoogleSignInButtonContentAlignment.hpp"
#include <optional>
#include "JGoogleSignInButtonContentAlignment.hpp"
#include <functional>
#include "JFunc_void.hpp"
#include <NitroModules/JNICallable.hpp>

namespace margelo::nitro::nitrogooglesignin {

  std::shared_ptr<JHybridGoogleSignInButtonSpec> JHybridGoogleSignInButtonSpec::JavaPart::getJHybridGoogleSignInButtonSpec() {
    auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
    auto castHybridObject = std::dynamic_pointer_cast<JHybridGoogleSignInButtonSpec>(hybridObject);
    if (castHybridObject == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to downcast JHybridObject to JHybridGoogleSignInButtonSpec!");
    }
    return castHybridObject;
  }

  jni::local_ref<JHybridGoogleSignInButtonSpec::CxxPart::jhybriddata> JHybridGoogleSignInButtonSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
    return makeCxxInstance(jThis);
  }

  std::shared_ptr<JHybridObject> JHybridGoogleSignInButtonSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
    auto castJavaPart = jni::dynamic_ref_cast<JHybridGoogleSignInButtonSpec::JavaPart>(javaPart);
    if (castJavaPart == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridGoogleSignInButtonSpec::JavaPart!");
    }
    return std::make_shared<JHybridGoogleSignInButtonSpec>(castJavaPart);
  }

  void JHybridGoogleSignInButtonSpec::CxxPart::registerNatives() {
    registerHybrid({
      makeNativeMethod("initHybrid", JHybridGoogleSignInButtonSpec::CxxPart::initHybrid),
    });
  }

  // Properties
  GoogleSignInButtonColorScheme JHybridGoogleSignInButtonSpec::getColorScheme() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JGoogleSignInButtonColorScheme>()>("getColorScheme");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridGoogleSignInButtonSpec::setColorScheme(GoogleSignInButtonColorScheme colorScheme) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JGoogleSignInButtonColorScheme> /* colorScheme */)>("setColorScheme");
    method(_javaPart, JGoogleSignInButtonColorScheme::fromCpp(colorScheme));
  }
  GoogleSignInButtonNativeSize JHybridGoogleSignInButtonSpec::getSize() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JGoogleSignInButtonNativeSize>()>("getSize");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridGoogleSignInButtonSpec::setSize(GoogleSignInButtonNativeSize size) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JGoogleSignInButtonNativeSize> /* size */)>("setSize");
    method(_javaPart, JGoogleSignInButtonNativeSize::fromCpp(size));
  }
  bool JHybridGoogleSignInButtonSpec::getDisabled() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("getDisabled");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  void JHybridGoogleSignInButtonSpec::setDisabled(bool disabled) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* disabled */)>("setDisabled");
    method(_javaPart, disabled);
  }
  std::optional<GoogleSignInButtonContentAlignment> JHybridGoogleSignInButtonSpec::getContentAlignment() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JGoogleSignInButtonContentAlignment>()>("getContentAlignment");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
  }
  void JHybridGoogleSignInButtonSpec::setContentAlignment(std::optional<GoogleSignInButtonContentAlignment> contentAlignment) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JGoogleSignInButtonContentAlignment> /* contentAlignment */)>("setContentAlignment");
    method(_javaPart, contentAlignment.has_value() ? JGoogleSignInButtonContentAlignment::fromCpp(contentAlignment.value()) : nullptr);
  }
  std::function<void()> JHybridGoogleSignInButtonSpec::getOnPress() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>()>("getOnPress_cxx");
    auto __result = method(_javaPart);
    return [&]() -> std::function<void()> {
      if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
        auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
        return downcast->cthis()->getFunction();
      } else {
        auto __resultRef = jni::make_global(__result);
        return JNICallable<JFunc_void, void()>(std::move(__resultRef));
      }
    }();
  }
  void JHybridGoogleSignInButtonSpec::setOnPress(const std::function<void()>& onPress) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* onPress */)>("setOnPress_cxx");
    method(_javaPart, JFunc_void_cxx::fromCpp(onPress));
  }

  // Methods
  

} // namespace margelo::nitro::nitrogooglesignin
