# Class StubSettings.Builder&lt;SettingsT,B&gt; (2.81.0)

2.81.0 (latest) 2.80.0 2.79.0 2.76.0 2.75.0 2.74.1 2.73.1 2.72.2 2.71.0 2.70.3 2.69.0 2.68.2 2.67.0 2.66.0 2.65.0 2.63.1 2.62.0 2.61.0 2.60.0 2.59.1 2.58.0 2.57.0 2.55.0 2.54.1 2.53.0 2.52.0 2.51.0 2.50.0 2.49.0 2.48.1 2.47.0 2.46.1 2.45.0 2.43.0 2.42.0 2.41.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.1 2.33.0 2.32.1 2.31.1 2.30.1 2.24.0 2.23.3 2.22.0 2.21.0 2.20.1 2.19.6 2.18.7 2.17.0 2.16.0 2.15.0 2.14.0 2.13.0 2.12.2 2.11.0 2.10.0 2.9.0 2.8.1 2.7.1

    public abstract static class StubSettings.Builder<SettingsT,B>

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> StubSettings.Builder\<SettingsT,B\>

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

| ## Type Parameters ||
|---|---|
| **Name** | **Description** |
| `SettingsT` |   |
| `B` |   |

## Static Methods

### applyToAllUnaryMethods(Iterable\<UnaryCallSettings.Builder\<?,?\>\> methodSettingsBuilders, ApiFunction\<UnaryCallSettings.Builder\<?,?\>,Void\> settingsUpdater)

    protected static void applyToAllUnaryMethods(Iterable<UnaryCallSettings.Builder<?,?>> methodSettingsBuilders, ApiFunction<UnaryCallSettings.Builder<?,?>,Void> settingsUpdater)

Applies the given settings updater function to the given method settings builders.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `methodSettingsBuilders` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html<https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallSettings.Builder<?,?>>` |
| `settingsUpdater` | `https://docs.cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiFunction.html<https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallSettings.Builder<?,?>,https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html>` |

## Constructors

### Builder()

    protected Builder()

### Builder(ClientContext clientContext)

    protected Builder(ClientContext clientContext)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `clientContext` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ClientContext` |

### Builder(StubSettings settings)

    protected Builder(StubSettings settings)

Create a builder from a StubSettings object.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StubSettings` |

## Methods

### \<B\>build()

    public abstract StubSettings<B> <B>build()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StubSettings<B>` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### getApiKey()

    public final String getApiKey()

Gets the API Key that was previously set on this Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getBackgroundExecutorProvider()

    public ExecutorProvider getBackgroundExecutorProvider()

Gets the ExecutorProvider that was previously set on this Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.core.ExecutorProvider` |   |

### getClock()

    public ApiClock getClock()

Gets the ApiClock that was previously set on this Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiClock.html` |   |

### getCredentialsProvider()

    public CredentialsProvider getCredentialsProvider()

Gets the CredentialsProvider that was previously set on this Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.core.CredentialsProvider` |   |

### getEndpoint()

    public String getEndpoint()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | the resolved endpoint when the Builder was created. If invoked after `StubSettings.newBuilder()` is called, it will return the clientSettingsEndpoint value. If other parameters are then set in the builder, the resolved endpoint is not automatically updated. The resolved endpoint will only be recomputed when the StubSettings is built again. |

### getExecutorProvider() (deprecated)

    public ExecutorProvider getExecutorProvider()

**Deprecated.** *Please use [#getBackgroundExecutorProvider()](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StubSettings.Builder#com_google_api_gax_rpc_StubSettings_Builder_getBackgroundExecutorProvider__).*

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.core.ExecutorProvider` |   |

### getGdchApiAudience()

    public String getGdchApiAudience()

Gets the GDCH API audience that was previously set in this Builder

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getHeaderProvider()

    public HeaderProvider getHeaderProvider()

Gets the custom HeaderProvider that was previously set on this Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.HeaderProvider` |   |

### getInternalHeaderProvider()

    protected HeaderProvider getInternalHeaderProvider()

Gets the internal HeaderProvider that was previously set on this Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.HeaderProvider` |   |

### getMtlsEndpoint()

    public String getMtlsEndpoint()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getQuotaProjectId()

    public String getQuotaProjectId()

Gets the QuotaProjectId that was previously set on this Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getStreamWatchdogCheckInterval()

    public Duration getStreamWatchdogCheckInterval()

> [!WARNING]
> **Obsolete**
>
> *Use getStreamWatchdogCheckIntervalDuration() instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#getStreamWatchdogCheckIntervalDuration()](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StubSettings.Builder#com_google_api_gax_rpc_StubSettings_Builder_getStreamWatchdogCheckIntervalDuration__) instead

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `org.threeten.bp.Duration` |   |

### getStreamWatchdogCheckIntervalDuration()

    public Duration getStreamWatchdogCheckIntervalDuration()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |   |

### getStreamWatchdogProvider()

    public WatchdogProvider getStreamWatchdogProvider()

Gets the [WatchdogProvider](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.WatchdogProvider)that was previously set on this Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.WatchdogProvider` |   |

### getTracerFactory()

    public ApiTracerFactory getTracerFactory()

> [!WARNING]
> **Beta**
>
> *The surface for tracing is not stable yet and may change in the future.*
>
> This feature is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracerFactory` |   |

### getTransportChannelProvider()

    public TransportChannelProvider getTransportChannelProvider()

Gets the TransportProvider that was previously set on this Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.TransportChannelProvider` |   |

### self()

    protected B self()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setApiKey(String apiKey)

    public B setApiKey(String apiKey)

Sets the API key. The API key will get translated to an com.google.auth.ApiKeyCredentials and stored in [ClientContext](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ClientContext).

API Key authorization is not supported for every product. Please check the documentation
for each product to confirm if it is supported.

Note: If you set an API key and [CredentialsProvider](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.core.CredentialsProvider) in the same ClientSettings the
API key will override any credentials provided.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `apiKey` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setBackgroundExecutorProvider(ExecutorProvider backgroundExecutorProvider)

    public B setBackgroundExecutorProvider(ExecutorProvider backgroundExecutorProvider)

Sets the executor to use for running scheduled API call logic (such as retries and
long-running operations).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `backgroundExecutorProvider` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.core.ExecutorProvider` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setClock(ApiClock clock)

    public B setClock(ApiClock clock)

Sets the clock to use for retry logic.

This will default to a system clock if it is not set.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `clock` | `https://docs.cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiClock.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setCredentialsProvider(CredentialsProvider credentialsProvider)

    public B setCredentialsProvider(CredentialsProvider credentialsProvider)

Sets the CredentialsProvider to use for getting the credentials to make calls with.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `credentialsProvider` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.core.CredentialsProvider` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setEndpoint(String endpoint)

    public B setEndpoint(String endpoint)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `endpoint` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setExecutorProvider(ExecutorProvider executorProvider) (deprecated)

    public B setExecutorProvider(ExecutorProvider executorProvider)

**Deprecated.** *Please use [#setBackgroundExecutorProvider(ExecutorProvider)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StubSettings.Builder#com_google_api_gax_rpc_StubSettings_Builder_setBackgroundExecutorProvider_com_google_api_gax_core_ExecutorProvider_) for setting
executor to use for running scheduled API call logic. To set executor for [TransportChannelProvider](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.TransportChannelProvider), please use [TransportChannelProvider#withExecutor(Executor)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.TransportChannelProvider#com_google_api_gax_rpc_TransportChannelProvider_withExecutor_java_util_concurrent_Executor_) instead.*

Sets the ExecutorProvider to use for getting the executor to use for running asynchronous API
call logic (such as retries and long-running operations), and also to pass to the transport
settings if an executor is needed for the transport and it doesn't have its own executor
provider.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `executorProvider` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.core.ExecutorProvider` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setGdchApiAudience(String gdchApiAudience)

    public B setGdchApiAudience(String gdchApiAudience)

Sets the API audience used by com.google.auth.oauth2.GdchCredentials It cannot be
used if other type of com.google.auth.Credentials is used. If the provided
credentials already have an api audience set, then it will be overriden by this audience

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `gdchApiAudience` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the audience to be used - must be a valid URI string |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setHeaderProvider(HeaderProvider headerProvider)

    public B setHeaderProvider(HeaderProvider headerProvider)

Sets the HeaderProvider for getting custom static headers for http requests. The header
provider will be called during client construction only once. The headers returned by the
provider will be cached and supplied as is for each request issued by the constructed client.
Some reserved headers can be overridden (e.g. Content-Type) or merged with the default value
(e.g. User-Agent) by the underlying transport layer.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `headerProvider` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.HeaderProvider` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setInternalHeaderProvider(HeaderProvider internalHeaderProvider)

    protected B setInternalHeaderProvider(HeaderProvider internalHeaderProvider)

Sets the HeaderProvider for getting internal (library-defined) static headers for http
requests. The header provider will be called during client construction only once. The
headers returned by the provider will be cached and supplied as is for each request issued by
the constructed client. Some reserved headers can be overridden (e.g. Content-Type) or merged
with the default value (e.g. User-Agent) by the underlying transport layer.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `internalHeaderProvider` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.HeaderProvider` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setMtlsEndpoint(String mtlsEndpoint)

    public B setMtlsEndpoint(String mtlsEndpoint)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `mtlsEndpoint` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setQuotaProjectId(String quotaProjectId)

    public B setQuotaProjectId(String quotaProjectId)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `quotaProjectId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setStreamWatchdogCheckInterval(Duration checkInterval)

    public B setStreamWatchdogCheckInterval(Duration checkInterval)

> [!WARNING]
> **Obsolete**
>
> *Use setStreamWatchdogCheckIntervalDuration(java.time.Duration) instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#setStreamWatchdogCheckIntervalDuration(java.time.Duration)](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.StubSettings.Builder#com_google_api_gax_rpc_StubSettings_Builder_setStreamWatchdogCheckIntervalDuration_java_time_Duration_) instead.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `checkInterval` | `org.threeten.bp.Duration` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setStreamWatchdogCheckIntervalDuration(Duration checkInterval)

    public B setStreamWatchdogCheckIntervalDuration(Duration checkInterval)

Sets how often the [Watchdog](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.Watchdog) will check ongoing streaming RPCs. Defaults to 10 secs.
Use java.time.Duration#ZERO to disable.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `checkInterval` | `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setStreamWatchdogProvider(WatchdogProvider streamWatchdogProvider)

    public B setStreamWatchdogProvider(WatchdogProvider streamWatchdogProvider)

Sets the [WatchdogProvider](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.WatchdogProvider) to use for streaming RPC.

This will default to a [InstantiatingWatchdogProvider](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.InstantiatingWatchdogProvider) if it is not set.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `streamWatchdogProvider` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.WatchdogProvider` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setSwitchToMtlsEndpointAllowed(boolean switchToMtlsEndpointAllowed)

    protected B setSwitchToMtlsEndpointAllowed(boolean switchToMtlsEndpointAllowed)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `switchToMtlsEndpointAllowed` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setTracerFactory(ApiTracerFactory tracerFactory)

    public B setTracerFactory(ApiTracerFactory tracerFactory)

> [!WARNING]
> **Beta**
>
> *The surface for tracing is not stable yet and may change in the future.*
>
> This feature is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the launch stage descriptions.

Configures the [ApiTracerFactory](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracerFactory) that will be used to generate traces.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `tracerFactory` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracerFactory` an instance of [ApiTracerFactory](https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracerFactory) to set. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setTransportChannelProvider(TransportChannelProvider transportChannelProvider)

    public B setTransportChannelProvider(TransportChannelProvider transportChannelProvider)

Sets the TransportProvider to use for getting the transport-specific context to make calls
with.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `transportChannelProvider` | `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.TransportChannelProvider` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### setUniverseDomain(String universeDomain)

    public B setUniverseDomain(String universeDomain)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `universeDomain` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `B` |   |

### toString()

    public String toString()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

**Overrides** [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)