Package com.cercalia.sdk
Class CercaliaClient
java.lang.Object
com.cercalia.sdk.CercaliaClient
- Direct Known Subclasses:
GeocodingService,GeofencingService,GeomentService,IsochroneService,PoiService,ProximityService,ReverseGeocodingService,RoutingService,SnapToRoadService,StaticMapsService,SuggestService
Abstract base class for all Cercalia API services.
This class provides the core HTTP request-response cycle infrastructure, including connection pooling, request authentication, retry mechanisms, and standard Cercalia XML/JSON response parsing.
Subclasses implement specific Cercalia services by defining parameters and mapping the results to high-level POJOs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CercaliaConfigprotected final okhttp3.OkHttpClientprotected final Loggerprotected final com.fasterxml.jackson.databind.ObjectMapper -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCercaliaClient(@NotNull CercaliaConfig config) Creates a new CercaliaClient with the specified configuration.protectedCercaliaClient(@NotNull CercaliaConfig config, @NotNull okhttp3.OkHttpClient httpClient) Creates a new CercaliaClient with a custom OkHttpClient. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds a parameter to the map if the value is not null.protected voidAdds a parameter to the map if the value is not null.protected voidAdds a parameter to the map if the value is not null or empty.protected voidAdds a boolean parameter to the map if the value is true.@NotNull CercaliaConfigReturns the configuration for this client.Creates a new parameter map.Creates a new parameter map with the specified command.protected com.fasterxml.jackson.databind.JsonNodeMakes a synchronous request to the Cercalia API.protected com.fasterxml.jackson.databind.JsonNodeMakes a synchronous request to the Cercalia API with a custom base URL.protected CompletableFuture<com.fasterxml.jackson.databind.JsonNode>requestAsync(@NotNull Map<String, String> params, @NotNull String operationName) Makes an asynchronous request to the Cercalia API.protected CompletableFuture<com.fasterxml.jackson.databind.JsonNode>Makes an asynchronous request to the Cercalia API with a custom base URL.
-
Field Details
-
config
-
httpClient
protected final okhttp3.OkHttpClient httpClient -
objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper -
logger
-
-
Constructor Details
-
CercaliaClient
Creates a new CercaliaClient with the specified configuration.- Parameters:
config- the Cercalia configuration
-
CercaliaClient
protected CercaliaClient(@NotNull @NotNull CercaliaConfig config, @NotNull @NotNull okhttp3.OkHttpClient httpClient) Creates a new CercaliaClient with a custom OkHttpClient.- Parameters:
config- the Cercalia configurationhttpClient- the custom HTTP client
-
-
Method Details
-
getConfig
Returns the configuration for this client.- Returns:
- the configuration
-
request
protected com.fasterxml.jackson.databind.JsonNode request(@NotNull @NotNull Map<String, String> params, @NotNull @NotNull String operationName) Makes a synchronous request to the Cercalia API.- Parameters:
params- the query parametersoperationName- the operation name for logging- Returns:
- the "cercalia" node from the response
- Throws:
CercaliaException- if the request fails or returns an error
-
request
protected com.fasterxml.jackson.databind.JsonNode request(@NotNull @NotNull Map<String, String> params, @NotNull @NotNull String operationName, String baseUrl) Makes a synchronous request to the Cercalia API with a custom base URL.- Parameters:
params- the query parametersoperationName- the operation name for loggingbaseUrl- the base URL (optional, uses config.baseUrl if null)- Returns:
- the "cercalia" node from the response
- Throws:
CercaliaException- if the request fails or returns an error
-
requestAsync
protected CompletableFuture<com.fasterxml.jackson.databind.JsonNode> requestAsync(@NotNull @NotNull Map<String, String> params, @NotNull @NotNull String operationName) Makes an asynchronous request to the Cercalia API.- Parameters:
params- the query parametersoperationName- the operation name for logging- Returns:
- a CompletableFuture with the "cercalia" node from the response
-
requestAsync
protected CompletableFuture<com.fasterxml.jackson.databind.JsonNode> requestAsync(@NotNull @NotNull Map<String, String> params, @NotNull @NotNull String operationName, String baseUrl) Makes an asynchronous request to the Cercalia API with a custom base URL.- Parameters:
params- the query parametersoperationName- the operation name for loggingbaseUrl- the base URL (optional, uses config.baseUrl if null)- Returns:
- a CompletableFuture with the "cercalia" node from the response
-
newParams
Creates a new parameter map.- Returns:
- a new HashMap for parameters
-
newParams
Creates a new parameter map with the specified command.- Parameters:
cmd- the command- Returns:
- a new HashMap with the command set
-
addIfPresent
Adds a parameter to the map if the value is not null or empty.- Parameters:
params- the parameter mapkey- the parameter keyvalue- the parameter value
-
addIfPresent
Adds a parameter to the map if the value is not null.- Parameters:
params- the parameter mapkey- the parameter keyvalue- the parameter value
-
addIfPresent
Adds a parameter to the map if the value is not null.- Parameters:
params- the parameter mapkey- the parameter keyvalue- the parameter value
-
addIfTrue
Adds a boolean parameter to the map if the value is true.- Parameters:
params- the parameter mapkey- the parameter keyvalue- the parameter valuetrueValue- the string value to use when true
-