Class GeoApiContext.Builder

  • Enclosing class:
    GeoApiContext

    public static class GeoApiContext.Builder
    extends java.lang.Object
    The Builder for GeoApiContext.
    • Method Detail

      • 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 in units.
        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 in units.
        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 in units.
        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 in units.
        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 - The ApiException to allow or deny being re-tried.
        allowedToRetry - Whether to allow or deny re-trying exception.
        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 authentication
        proxyUserPassword - username for proxy authentication
        Returns:
        Returns this builder for call chaining.
      • build

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