类 GeoApiContext.Builder

java.lang.Object
ai.nextbillion.maps.GeoApiContext.Builder
封闭类:
GeoApiContext

public static class GeoApiContext.Builder
extends java.lang.Object
The Builder for GeoApiContext.
  • 构造器详细资料

  • 方法详细资料

    • requestHandlerBuilder

      public GeoApiContext.Builder requestHandlerBuilder​(GeoApiContext.RequestHandler.Builder builder)
      Changes the RequestHandler.Builder strategy to change between the OkHttpRequestHandler and the GaeRequestHandler.
      参数:
      builder - The RequestHandler.Builder to use for build()
      返回:
      Returns this builder for call chaining.
      另请参阅:
      OkHttpRequestHandler, GaeRequestHandler
    • hostName

      public GeoApiContext.Builder hostName​(java.lang.String hostName)
      Overrides the base URL of the API endpoint. Useful for testing or certain international usage scenarios.
      参数:
      hostName - The URL to use, without a trailing slash
      返回:
      Returns this builder for call chaining.
    • apiKey

      public GeoApiContext.Builder apiKey​(java.lang.String apiKey)
      Sets the API Key to use for authorizing requests.
      参数:
      apiKey - The API Key to use.
      返回:
      Returns this builder for call chaining.
    • apiKeyInQuery

      public GeoApiContext.Builder apiKeyInQuery​(boolean apiKeyInQuery)
      Sets the API Key to use for authorizing requests.
      参数:
      apiKeyInQuery - apiKeyInQuery
      返回:
      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. Most users should use apiKey(String) instead.
      参数:
      clientId - The Client ID to use.
      cryptographicSecret - The Secret to use.
      返回:
      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.
      参数:
      channel - The channel to use for analytics
      返回:
      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.
      参数:
      timeout - The connect timeout period in units.
      unit - The connect timeout time unit.
      返回:
      Returns this builder for call chaining.
      另请参阅:
      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.
      参数:
      timeout - The read timeout period in units.
      unit - The read timeout time unit.
      返回:
      Returns this builder for call chaining.
      另请参阅:
      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.
      参数:
      timeout - The write timeout period in units.
      unit - The write timeout time unit.
      返回:
      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).

      参数:
      timeout - The retry timeout period in units.
      unit - The retry timeout time unit.
      返回:
      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).

      参数:
      maxRetries - The maximum number of times to retry.
      返回:
      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 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).
      参数:
      maxQps - The maximum queries per second.
      返回:
      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.
      参数:
      exception - The ApiException to allow or deny being re-tried.
      allowedToRetry - Whether to allow or deny re-trying exception.
      返回:
      Returns this builder for call chaining.
    • proxy

      public GeoApiContext.Builder proxy​(java.net.Proxy proxy)
      Sets the proxy for new connections.
      参数:
      proxy - The proxy to be used by the underlying HTTP client.
      返回:
      Returns this builder for call chaining.
    • proxyAuthentication

      public GeoApiContext.Builder proxyAuthentication​(java.lang.String proxyUserName, java.lang.String proxyUserPassword)
      set authentication for proxy
      参数:
      proxyUserName - username for proxy authentication
      proxyUserPassword - username for proxy authentication
      返回:
      Returns this builder for call chaining.
    • experienceId

      public GeoApiContext.Builder experienceId​(java.lang.String... experienceId)
      Sets the value for the HTTP header field name HttpHeaders.X_GOOG_MAPS_EXPERIENCE_ID HTTP header value for the field name on subsequent API calls.
      参数:
      experienceId - The experience ID
      返回:
      Returns this builder for call chaining.
    • requestMetricsReporter

      public GeoApiContext.Builder requestMetricsReporter​(RequestMetricsReporter requestMetricsReporter)
    • build

      public GeoApiContext build()
      Converts this builder into a GeoApiContext.
      返回:
      Returns the built GeoApiContext.