io.deepsense.neptune.clientlibrary.services.apiservice.ApiServiceBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neptune-client-library Show documentation
Show all versions of neptune-client-library Show documentation
Enables integration with Neptune in your Java code
/**
* Copyright (c) 2016, CodiLime Inc.
*/
package io.deepsense.neptune.clientlibrary.services.apiservice;
import io.deepsense.neptune.clientlibrary.api.Credentials;
import io.deepsense.neptune.clientlibrary.services.apimodelconverter.ApiModelConverter;
import io.deepsense.neptune.clientlibrary.services.apiservice.retries.ApiServiceWithRetries;
import io.deepsense.neptune.clientlibrary.services.apiservice.retries.RequestRetryStrategyFactory;
import java.net.URI;
public class ApiServiceBuilder {
private URI baseUrl;
private ApiModelConverter apiModelConverter;
private Credentials credentials;
private RequestRetryStrategyFactory retryStrategyFactory;
public ApiServiceBuilder() {
}
public ApiServiceBuilder withBaseUrl(URI baseUrl) {
this.baseUrl = baseUrl;
return this;
}
public ApiServiceBuilder withCredentials(Credentials credentials) {
this.credentials = credentials;
return this;
}
public ApiServiceBuilder withApiModelConverter(ApiModelConverter apiModelConverter) {
this.apiModelConverter = apiModelConverter;
return this;
}
public ApiServiceBuilder withRequestRetryStrategyFactory(RequestRetryStrategyFactory retryStrategyFactory) {
this.retryStrategyFactory = retryStrategyFactory;
return this;
}
public ApiService build() {
ApiService baseApiService = new SimpleApiService(apiModelConverter, credentials, baseUrl.toString());
if (retryStrategyFactory == null) {
return baseApiService;
} else {
return new ApiServiceWithRetries(baseApiService, retryStrategyFactory.create());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy