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

com.checkout.AbstractCheckoutSdkBuilder Maven / Gradle / Ivy

There is a newer version: 6.4.2
Show newest version
package com.checkout;

import java.util.concurrent.Executor;
import java.util.concurrent.ForkJoinPool;
import org.apache.http.impl.client.HttpClientBuilder;

public abstract class AbstractCheckoutSdkBuilder {

    protected HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
    private IEnvironment environment;
    private Executor executor = ForkJoinPool.commonPool();

    public AbstractCheckoutSdkBuilder environment(final IEnvironment environment) {
        this.environment = environment;
        return this;
    }

    public AbstractCheckoutSdkBuilder httpClientBuilder(final HttpClientBuilder httpClientBuilder) {
        this.httpClientBuilder = httpClientBuilder;
        return this;
    }

    public AbstractCheckoutSdkBuilder executor(final Executor executor) {
        this.executor = executor;
        return this;
    }

    protected IEnvironment getEnvironment() {
        return environment;
    }

    protected abstract SdkCredentials getSdkCredentials();

    protected CheckoutConfiguration getCheckoutConfiguration() {
        if (environment == null) {
            throw new CheckoutArgumentException("environment must be specified");
        }
        final SdkCredentials sdkCredentials = getSdkCredentials();
        return buildCheckoutConfiguration(sdkCredentials);
    }

    private CheckoutConfiguration buildCheckoutConfiguration(final SdkCredentials sdkCredentials) {
        return new DefaultCheckoutConfiguration(sdkCredentials, getEnvironment(), httpClientBuilder, executor);
    }

    public abstract T build();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy