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

#include "JHybridCameraControllerSpec.hpp"

// Forward declaration of `HybridCameraDeviceSpec` to properly resolve imports.
namespace margelo::nitro::camera { class HybridCameraDeviceSpec; }
// Forward declaration of `TorchMode` to properly resolve imports.
namespace margelo::nitro::camera { enum class TorchMode; }
// Forward declaration of `FocusMode` to properly resolve imports.
namespace margelo::nitro::camera { enum class FocusMode; }
// Forward declaration of `ExposureMode` to properly resolve imports.
namespace margelo::nitro::camera { enum class ExposureMode; }
// Forward declaration of `WhiteBalanceMode` to properly resolve imports.
namespace margelo::nitro::camera { enum class WhiteBalanceMode; }
// Forward declaration of `WhiteBalanceGains` to properly resolve imports.
namespace margelo::nitro::camera { struct WhiteBalanceGains; }
// Forward declaration of `ListenerSubscription` to properly resolve imports.
namespace margelo::nitro::camera { struct ListenerSubscription; }
// Forward declaration of `CameraControllerConfiguration` to properly resolve imports.
namespace margelo::nitro::camera { struct CameraControllerConfiguration; }
// Forward declaration of `HybridMeteringPointSpec` to properly resolve imports.
namespace margelo::nitro::camera { class HybridMeteringPointSpec; }
// Forward declaration of `FocusOptions` to properly resolve imports.
namespace margelo::nitro::camera { struct FocusOptions; }
// Forward declaration of `FocusResponsiveness` to properly resolve imports.
namespace margelo::nitro::camera { enum class FocusResponsiveness; }
// Forward declaration of `SceneAdaptiveness` to properly resolve imports.
namespace margelo::nitro::camera { enum class SceneAdaptiveness; }
// Forward declaration of `MeteringMode` to properly resolve imports.
namespace margelo::nitro::camera { enum class MeteringMode; }
// Forward declaration of `WhiteBalanceTemperatureAndTint` to properly resolve imports.
namespace margelo::nitro::camera { struct WhiteBalanceTemperatureAndTint; }

#include <memory>
#include "HybridCameraDeviceSpec.hpp"
#include "JHybridCameraDeviceSpec.hpp"
#include "TorchMode.hpp"
#include "JTorchMode.hpp"
#include "FocusMode.hpp"
#include "JFocusMode.hpp"
#include "ExposureMode.hpp"
#include "JExposureMode.hpp"
#include "WhiteBalanceMode.hpp"
#include "JWhiteBalanceMode.hpp"
#include "WhiteBalanceGains.hpp"
#include "JWhiteBalanceGains.hpp"
#include <NitroModules/Promise.hpp>
#include <NitroModules/JPromise.hpp>
#include <NitroModules/JUnit.hpp>
#include "ListenerSubscription.hpp"
#include "JListenerSubscription.hpp"
#include <functional>
#include "JFunc_void.hpp"
#include <NitroModules/JNICallable.hpp>
#include "CameraControllerConfiguration.hpp"
#include "JCameraControllerConfiguration.hpp"
#include <optional>
#include "HybridMeteringPointSpec.hpp"
#include "JHybridMeteringPointSpec.hpp"
#include "FocusOptions.hpp"
#include "JFocusOptions.hpp"
#include "FocusResponsiveness.hpp"
#include "JFocusResponsiveness.hpp"
#include "SceneAdaptiveness.hpp"
#include "JSceneAdaptiveness.hpp"
#include "MeteringMode.hpp"
#include <vector>
#include "JMeteringMode.hpp"
#include <NitroModules/Null.hpp>
#include <variant>
#include "JVariant_NullType_Double.hpp"
#include <NitroModules/JNull.hpp>
#include "WhiteBalanceTemperatureAndTint.hpp"
#include "JWhiteBalanceTemperatureAndTint.hpp"

namespace margelo::nitro::camera {

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

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

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

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

  // Properties
  std::shared_ptr<HybridCameraDeviceSpec> JHybridCameraControllerSpec::getDevice() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridCameraDeviceSpec::JavaPart>()>("getDevice");
    auto __result = method(_javaPart);
    return __result->getJHybridCameraDeviceSpec();
  }
  bool JHybridCameraControllerSpec::getIsConnected() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isConnected");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  bool JHybridCameraControllerSpec::getIsSuspended() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isSuspended");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  bool JHybridCameraControllerSpec::getIsUsedByAnotherApp() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isUsedByAnotherApp");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  bool JHybridCameraControllerSpec::getIsLowLightBoostEnabled() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isLowLightBoostEnabled");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  bool JHybridCameraControllerSpec::getIsSmoothAutoFocusEnabled() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isSmoothAutoFocusEnabled");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  bool JHybridCameraControllerSpec::getIsDistortionCorrectionEnabled() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isDistortionCorrectionEnabled");
    auto __result = method(_javaPart);
    return static_cast<bool>(__result);
  }
  double JHybridCameraControllerSpec::getZoom() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getZoom");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridCameraControllerSpec::getMinZoom() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getMinZoom");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridCameraControllerSpec::getMaxZoom() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getMaxZoom");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridCameraControllerSpec::getDisplayableZoomFactor() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getDisplayableZoomFactor");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridCameraControllerSpec::getTorchStrength() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getTorchStrength");
    auto __result = method(_javaPart);
    return __result;
  }
  TorchMode JHybridCameraControllerSpec::getTorchMode() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JTorchMode>()>("getTorchMode");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  double JHybridCameraControllerSpec::getExposureBias() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getExposureBias");
    auto __result = method(_javaPart);
    return __result;
  }
  FocusMode JHybridCameraControllerSpec::getFocusMode() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFocusMode>()>("getFocusMode");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  double JHybridCameraControllerSpec::getLensPosition() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getLensPosition");
    auto __result = method(_javaPart);
    return __result;
  }
  ExposureMode JHybridCameraControllerSpec::getExposureMode() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JExposureMode>()>("getExposureMode");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  double JHybridCameraControllerSpec::getMinExposureDuration() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getMinExposureDuration");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridCameraControllerSpec::getMaxExposureDuration() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getMaxExposureDuration");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridCameraControllerSpec::getMinISO() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getMinISO");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridCameraControllerSpec::getMaxISO() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getMaxISO");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridCameraControllerSpec::getExposureDuration() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getExposureDuration");
    auto __result = method(_javaPart);
    return __result;
  }
  double JHybridCameraControllerSpec::getIso() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getIso");
    auto __result = method(_javaPart);
    return __result;
  }
  WhiteBalanceMode JHybridCameraControllerSpec::getWhiteBalanceMode() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JWhiteBalanceMode>()>("getWhiteBalanceMode");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  WhiteBalanceGains JHybridCameraControllerSpec::getWhiteBalanceGains() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JWhiteBalanceGains>()>("getWhiteBalanceGains");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }

  // Methods
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::configure(const CameraControllerConfiguration& config) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JCameraControllerConfiguration> /* config */)>("configure");
    auto __result = method(_javaPart, JCameraControllerConfiguration::fromCpp(config));
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::focusTo(const std::shared_ptr<HybridMeteringPointSpec>& point, const FocusOptions& options) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JHybridMeteringPointSpec::JavaPart> /* point */, jni::alias_ref<JFocusOptions> /* options */)>("focusTo");
    auto __result = method(_javaPart, std::dynamic_pointer_cast<JHybridMeteringPointSpec>(point)->getJavaPart(), JFocusOptions::fromCpp(options));
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::resetFocus() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("resetFocus");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  ListenerSubscription JHybridCameraControllerSpec::addSubjectAreaChangedListener(const std::function<void()>& onSubjectAreaChanged) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JListenerSubscription>(jni::alias_ref<JFunc_void::javaobject> /* onSubjectAreaChanged */)>("addSubjectAreaChangedListener_cxx");
    auto __result = method(_javaPart, JFunc_void_cxx::fromCpp(onSubjectAreaChanged));
    return __result->toCpp();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::setZoom(double zoom) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(double /* zoom */)>("setZoom");
    auto __result = method(_javaPart, zoom);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::startZoomAnimation(double zoom, double rate) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(double /* zoom */, double /* rate */)>("startZoomAnimation");
    auto __result = method(_javaPart, zoom, rate);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::cancelZoomAnimation() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("cancelZoomAnimation");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::setTorchMode(TorchMode mode) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JTorchMode> /* mode */)>("setTorchMode");
    auto __result = method(_javaPart, JTorchMode::fromCpp(mode));
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::enableTorchWithStrength(double strength) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(double /* strength */)>("enableTorchWithStrength");
    auto __result = method(_javaPart, strength);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::setExposureBias(double exposure) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(double /* exposure */)>("setExposureBias");
    auto __result = method(_javaPart, exposure);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::setFocusLocked(double lensPosition) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(double /* lensPosition */)>("setFocusLocked");
    auto __result = method(_javaPart, lensPosition);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::lockCurrentFocus() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("lockCurrentFocus");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::setExposureLocked(double duration, double iso) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(double /* duration */, double /* iso */)>("setExposureLocked");
    auto __result = method(_javaPart, duration, iso);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::lockCurrentExposure() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("lockCurrentExposure");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  WhiteBalanceGains JHybridCameraControllerSpec::convertWhiteBalanceTemperatureAndTintValues(const WhiteBalanceTemperatureAndTint& whiteBalanceTemperatureAndTint) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JWhiteBalanceGains>(jni::alias_ref<JWhiteBalanceTemperatureAndTint> /* whiteBalanceTemperatureAndTint */)>("convertWhiteBalanceTemperatureAndTintValues");
    auto __result = method(_javaPart, JWhiteBalanceTemperatureAndTint::fromCpp(whiteBalanceTemperatureAndTint));
    return __result->toCpp();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::setWhiteBalanceLocked(const WhiteBalanceGains& whiteBalanceGains) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JWhiteBalanceGains> /* whiteBalanceGains */)>("setWhiteBalanceLocked");
    auto __result = method(_javaPart, JWhiteBalanceGains::fromCpp(whiteBalanceGains));
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridCameraControllerSpec::lockCurrentWhiteBalance() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("lockCurrentWhiteBalance");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }

} // namespace margelo::nitro::camera
