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

#include "JHybridMMKVPlatformContextSpec.hpp"



#include <string>
#include <optional>

namespace margelo::nitro::mmkv {

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

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

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

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

  // Properties
  

  // Methods
  std::string JHybridMMKVPlatformContextSpec::getBaseDirectory() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getBaseDirectory");
    auto __result = method(_javaPart);
    return __result->toStdString();
  }
  std::optional<std::string> JHybridMMKVPlatformContextSpec::getAppGroupDirectory() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getAppGroupDirectory");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
  }

} // namespace margelo::nitro::mmkv
