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

com.adobe.platform.operation.internal.InternalClientConfig Maven / Gradle / Ivy

/*
 * Copyright 2019 Adobe
 * All Rights Reserved.
 *
 * NOTICE: Adobe permits you to use, modify, and distribute this file in
 * accordance with the terms of the Adobe license agreement accompanying
 * it. If you have received this file from a source other than Adobe,
 * then your use, modification, or distribution of it requires the prior
 * written permission of Adobe.
 */

package com.adobe.platform.operation.internal;

import com.adobe.platform.operation.ClientConfig;

public class InternalClientConfig extends ClientConfig {

    private Integer connectTimeout;
    private Integer socketTimeout;
    private String v2PredictUri;

    public InternalClientConfig(Integer connectTimeout, Integer socketTimeout, String v2ServicesPredictUri) {
        this.connectTimeout = connectTimeout!=null ? connectTimeout : GlobalConfig.getConnectTimeout();
        this.socketTimeout = socketTimeout!=null ? socketTimeout : GlobalConfig.getSocketTimeout();
        this.v2PredictUri = v2ServicesPredictUri!=null ? v2ServicesPredictUri : GlobalConfig.getV2PredictUri();
    }

    public InternalClientConfig() {
        this.connectTimeout = GlobalConfig.getConnectTimeout();
        this.socketTimeout = GlobalConfig.getSocketTimeout();
        this.v2PredictUri = GlobalConfig.getV2PredictUri();
    }

    Integer getConnectTimeout() {
        return connectTimeout;
    }

    Integer getSocketTimeout() {
        return socketTimeout;
    }

    public String getV2PredictUri() {
        return v2PredictUri;
    }

    public void validate() {
        if (this.socketTimeout <= 0) {
            throw new IllegalArgumentException(String.format("Invalid value for socket timeout %s Must be valid integer greater than 0",
                    this.socketTimeout));
        }

        if (this.connectTimeout <= 0) {
            throw new IllegalArgumentException(String.format("Invalid value for connect timeout %s Must be valid integer greater than 0",
                    this.connectTimeout));
        }
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy