
io.sphere.sdk.client.PlayJavaSphereClientImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commercetools-play-2_3-java-client_2.10 Show documentation
Show all versions of commercetools-play-2_3-java-client_2.10 Show documentation
commercetools-play-2_3-java-client
package io.sphere.sdk.client;
import play.libs.F;
import java.util.concurrent.CompletionStage;
final class PlayJavaSphereClientImpl implements PlayJavaSphereClient {
private final SphereClient sphereClient;
private PlayJavaSphereClientImpl(final SphereClient sphereClient) {
this.sphereClient = sphereClient;
}
@Override
public F.Promise execute(final SphereRequest sphereRequest) {
return convert(sphereClient.execute(sphereRequest));
}
@Override
public void close() {
sphereClient.close();
}
private static F.Promise convert(final CompletionStage stage) {
F.RedeemablePromise promise = F.RedeemablePromise.empty();
stage.whenCompleteAsync((value, throwable) -> {
if (throwable == null) {
promise.success(value);
} else {
promise.failure(throwable);
}
});
return promise;
}
public static PlayJavaSphereClient of(final SphereClient sphereClient) {
return new PlayJavaSphereClientImpl(sphereClient);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy