Package org.eclipse.sw360.http.config
Class HttpClientConfig
- java.lang.Object
-
- org.eclipse.sw360.http.config.HttpClientConfig
-
public final class HttpClientConfig extends Object
A class collecting all configuration options supported by the HTTP client library.
An object of this class is needed to create a new
HttpClientinstance. There is a default instance available, which can be adapted by changing configuration options. Instances are immutable; changing an option returns a modified copy.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HttpClientConfigbasicConfig()Returns a basicHttpClientConfiginstance.Optional<com.fasterxml.jackson.databind.ObjectMapper>customObjectMapper()Returns anOptionalwith a custom JSON object mapper to be used for dealing with JSON payload.booleanequals(Object o)com.fasterxml.jackson.databind.ObjectMappergetOrCreateObjectMapper()Returns anObjectMapperinstance that is either the custom mapper which has been set explicitly or a newly created instance.inthashCode()ProxySettingsproxySettings()Returns aProxySettingsobject with the proxy configuration to be used.HttpClientConfigwithObjectMapper(com.fasterxml.jackson.databind.ObjectMapper newMapper)Returns a new instance ofHttpClientConfigthat contains the same settings as this instance, but with the JSON object mapper set to the parameter specified.HttpClientConfigwithProxySettings(ProxySettings newProxySettings)Returns a new instance ofHttpClientConfigthat contains the same settings as this instance, but with the proxy configuration set to the parameter specified.
-
-
-
Method Detail
-
basicConfig
public static HttpClientConfig basicConfig()
Returns a basicHttpClientConfiginstance. This instance contains a minimum configuration. It can be used for simple use cases or serve as a starting point for constructing custom configurations.- Returns:
- the basic configuration instance
-
customObjectMapper
public Optional<com.fasterxml.jackson.databind.ObjectMapper> customObjectMapper()
Returns anOptionalwith a custom JSON object mapper to be used for dealing with JSON payload. If thisOptionalis empty, a new mapper (without a special configuration) is created and used by the HTTP client.- Returns:
- an
Optionalwith a custom JSON object mapper
-
getOrCreateObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getOrCreateObjectMapper()
Returns anObjectMapperinstance that is either the custom mapper which has been set explicitly or a newly created instance. This method can be used to obtain a correct and non-null JSON mapper instance.- Returns:
- the JSON mapper configured by this class
-
proxySettings
public ProxySettings proxySettings()
Returns aProxySettingsobject with the proxy configuration to be used.- Returns:
- the proxy configuration for the HTTP library
-
withObjectMapper
public HttpClientConfig withObjectMapper(com.fasterxml.jackson.databind.ObjectMapper newMapper)
Returns a new instance ofHttpClientConfigthat contains the same settings as this instance, but with the JSON object mapper set to the parameter specified.- Parameters:
newMapper- the JSON object mapper (can be null to remove a special custom object mapper)- Returns:
- the new
HttpClientConfiginstance
-
withProxySettings
public HttpClientConfig withProxySettings(ProxySettings newProxySettings)
Returns a new instance ofHttpClientConfigthat contains the same settings as this instance, but with the proxy configuration set to the parameter specified.- Parameters:
newProxySettings- the proxy configuration to be set- Returns:
- the new
HttpClientConfiginstance
-
-