All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.client.BlockingSphereClientImpl Maven / Gradle / Ivy

package io.sphere.sdk.client;

import java.util.concurrent.*;

import static io.sphere.sdk.client.SphereClientUtils.blockingWait;

class BlockingSphereClientImpl implements BlockingSphereClient {

    private final SphereClient delegate;
    private final long defaultTimeout;
    private final TimeUnit unit;

    public BlockingSphereClientImpl(final SphereClient delegate, final long defaultTimeout, final TimeUnit unit) {
        this.delegate = delegate;
        this.defaultTimeout = defaultTimeout;
        this.unit = unit;
    }

    @Override
    public void close() {
        delegate.close();
    }

    @Override
    public  CompletionStage execute(final SphereRequest sphereRequest) {
        return delegate.execute(sphereRequest);
    }

    @Override
    public  T executeBlocking(final SphereRequest sphereRequest) {
        return executeBlocking(sphereRequest, defaultTimeout, unit);
    }

    @Override
    public  T executeBlocking(final SphereRequest sphereRequest, final long timeout, final TimeUnit unit) {
        final CompletionStage completionStage = execute(sphereRequest);
        return blockingWait(completionStage, timeout, unit);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy