
io.sphere.sdk.client.CompletableFutureMapper Maven / Gradle / Ivy
package io.sphere.sdk.client;
import scala.concurrent.Promise;
import java.util.function.BiConsumer;
//default methods of Java interfaces do not work in Scala
final class CompletableFutureMapper implements BiConsumer {
private final Promise promise;
public CompletableFutureMapper(final Promise promise) {
this.promise = promise;
}
@Override
public void accept(final T value, final Throwable throwable) {
final boolean hasError = throwable != null;
if (hasError) {
promise.failure(throwable);
} else {
promise.success(value);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy