Package com.google.maps
Class GeoApiContext.Builder
- java.lang.Object
-
- com.google.maps.GeoApiContext.Builder
-
- Enclosing class:
- GeoApiContext
public static class GeoApiContext.Builder extends java.lang.Object
The Builder forGeoApiContext
.
-
-
Constructor Summary
Constructors Constructor Description Builder()
Builder pattern for the enclosingGeoApiContext
.Builder(GeoApiContext.RequestHandler.Builder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GeoApiContext.Builder
apiKey(java.lang.String apiKey)
Sets the API Key to use for authorizing requests.GeoApiContext
build()
Converts this builder into aGeoApiContext
.GeoApiContext.Builder
channel(java.lang.String channel)
Sets the default channel for requests (can be overridden by requests).GeoApiContext.Builder
connectTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the default connect timeout for new connections.GeoApiContext.Builder
disableRetries()
Disables retries completely, by setting max retries to 0 and retry timeout to 0.GeoApiContext.Builder
enterpriseCredentials(java.lang.String clientId, java.lang.String cryptographicSecret)
Sets the ClientID/Secret pair to use for authorizing requests.GeoApiContext.Builder
maxRetries(java.lang.Integer maxRetries)
Sets the maximum number of times each retry-able errors will be retried.GeoApiContext.Builder
proxy(java.net.Proxy proxy)
Sets the proxy for new connections.GeoApiContext.Builder
proxyAuthentication(java.lang.String proxyUserName, java.lang.String proxyUserPassword)
set authentication for proxyGeoApiContext.Builder
queryRateLimit(int maxQps)
Sets the maximum number of queries that will be executed during a 1 second interval.GeoApiContext.Builder
readTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the default read timeout for new connections.GeoApiContext.Builder
requestHandlerBuilder(GeoApiContext.RequestHandler.Builder builder)
Changes the RequestHandler.Builder strategy to change between theOkHttpRequestHandler
and theGaeRequestHandler
.GeoApiContext.Builder
retryTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the cumulative time limit for which retry-able errors will be retried.GeoApiContext.Builder
setIfExceptionIsAllowedToRetry(java.lang.Class<? extends ApiException> exception, boolean allowedToRetry)
Allows specific API exceptions to be retried or not retried.GeoApiContext.Builder
writeTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the default write timeout for new connections.
-
-
-
Constructor Detail
-
Builder
public Builder()
Builder pattern for the enclosingGeoApiContext
.
-
Builder
public Builder(GeoApiContext.RequestHandler.Builder builder)
-
-
Method Detail
-
requestHandlerBuilder
public GeoApiContext.Builder requestHandlerBuilder(GeoApiContext.RequestHandler.Builder builder)
Changes the RequestHandler.Builder strategy to change between theOkHttpRequestHandler
and theGaeRequestHandler
.- Parameters:
builder
- TheRequestHandler.Builder
to use forbuild()
- Returns:
- Returns this builder for call chaining.
- See Also:
OkHttpRequestHandler
,GaeRequestHandler
-
apiKey
public GeoApiContext.Builder apiKey(java.lang.String apiKey)
Sets the API Key to use for authorizing requests.- Parameters:
apiKey
- The API Key to use.- Returns:
- Returns this builder for call chaining.
-
enterpriseCredentials
public GeoApiContext.Builder enterpriseCredentials(java.lang.String clientId, java.lang.String cryptographicSecret)
Sets the ClientID/Secret pair to use for authorizing requests.- Parameters:
clientId
- The Client ID to use.cryptographicSecret
- The Secret to use.- Returns:
- Returns this builder for call chaining.
-
channel
public GeoApiContext.Builder channel(java.lang.String channel)
Sets the default channel for requests (can be overridden by requests). Only useful for Google Maps for Work clients.- Parameters:
channel
- The channel to use for analytics- Returns:
- Returns this builder for call chaining.
-
connectTimeout
public GeoApiContext.Builder connectTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the default connect timeout for new connections. A value of 0 means no timeout.- Parameters:
timeout
- The connect timeout period inunit
s.unit
- The connect timeout time unit.- Returns:
- Returns this builder for call chaining.
- See Also:
URLConnection.setConnectTimeout(int)
-
readTimeout
public GeoApiContext.Builder readTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the default read timeout for new connections. A value of 0 means no timeout.- Parameters:
timeout
- The read timeout period inunit
s.unit
- The read timeout time unit.- Returns:
- Returns this builder for call chaining.
- See Also:
URLConnection.setReadTimeout(int)
-
writeTimeout
public GeoApiContext.Builder writeTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the default write timeout for new connections. A value of 0 means no timeout.- Parameters:
timeout
- The write timeout period inunit
s.unit
- The write timeout time unit.- Returns:
- Returns this builder for call chaining.
-
retryTimeout
public GeoApiContext.Builder retryTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Sets the cumulative time limit for which retry-able errors will be retried. Defaults to 60 seconds. Set to zero to retry requests forever.This operates separately from the count-based
maxRetries(Integer)
.- Parameters:
timeout
- The retry timeout period inunit
s.unit
- The retry timeout time unit.- Returns:
- Returns this builder for call chaining.
-
maxRetries
public GeoApiContext.Builder maxRetries(java.lang.Integer maxRetries)
Sets the maximum number of times each retry-able errors will be retried. Set this to null to not have a max number. Set this to zero to disable retries.This operates separately from the time-based
retryTimeout(long, TimeUnit)
.- Parameters:
maxRetries
- The maximum number of times to retry.- Returns:
- Returns this builder for call chaining.
-
disableRetries
public GeoApiContext.Builder disableRetries()
Disables retries completely, by setting max retries to 0 and retry timeout to 0.- Returns:
- Returns this builder for call chaining.
-
queryRateLimit
public GeoApiContext.Builder queryRateLimit(int maxQps)
Sets the maximum number of queries that will be executed during a 1 second interval. The default is 50. A minimum interval between requests will also be enforced, set to 1/(2 *maxQps
).- Parameters:
maxQps
- The maximum queries per second.- Returns:
- Returns this builder for call chaining.
-
setIfExceptionIsAllowedToRetry
public GeoApiContext.Builder setIfExceptionIsAllowedToRetry(java.lang.Class<? extends ApiException> exception, boolean allowedToRetry)
Allows specific API exceptions to be retried or not retried.- Parameters:
exception
- TheApiException
to allow or deny being re-tried.allowedToRetry
- Whether to allow or deny re-tryingexception
.- Returns:
- Returns this builder for call chaining.
-
proxy
public GeoApiContext.Builder proxy(java.net.Proxy proxy)
Sets the proxy for new connections.- Parameters:
proxy
- The proxy to be used by the underlying HTTP client.- Returns:
- Returns this builder for call chaining.
-
proxyAuthentication
public GeoApiContext.Builder proxyAuthentication(java.lang.String proxyUserName, java.lang.String proxyUserPassword)
set authentication for proxy- Parameters:
proxyUserName
- username for proxy authenticationproxyUserPassword
- username for proxy authentication- Returns:
- Returns this builder for call chaining.
-
build
public GeoApiContext build()
Converts this builder into aGeoApiContext
.- Returns:
- Returns the built
GeoApiContext
.
-
-