[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  
Summary:[Ctors](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder#pubctors)\|[Methods](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder#inhmethods)  

# KeyedFrequencyCap.Builder

`
public
static
final

class
KeyedFrequencyCap.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-----------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.adservices.common.KeyedFrequencyCap.Builder |

<br />

*** ** * ** ***

Builder for creating[KeyedFrequencyCap](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap)objects.

## Summary

|                                                                                                                                        ### Public constructors                                                                                                                                         ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder#Builder(int,%20int,%20java.time.Duration))`(int adCounterKey, int maxCount, `[Duration](https://developer.android.com/reference/java/time/Duration)` interval) ` |

|                                                                                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                                                                                              ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[KeyedFrequencyCap](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap)                 | ` `[build](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder#build())`() ` Builds and returns a[KeyedFrequencyCap](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap)instance.                                                                                                                                        |
| ` `[KeyedFrequencyCap.Builder](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder) | ` `[setAdCounterKey](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder#setAdCounterKey(int))`(int adCounterKey) ` Sets the ad counter key the frequency cap applies to.                                                                                                                                                                                                           |
| ` `[KeyedFrequencyCap.Builder](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder) | ` `[setInterval](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder#setInterval(java.time.Duration))`(`[Duration](https://developer.android.com/reference/java/time/Duration)` interval) ` Sets the interval, as a[Duration](https://developer.android.com/reference/java/time/Duration)which will be truncated to the nearest second, over which the frequency cap is calculated. |
| ` `[KeyedFrequencyCap.Builder](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder) | ` `[setMaxCount](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder#setMaxCount(int))`(int maxCount) ` Sets the maximum count within the time interval for the frequency cap.                                                                                                                                                                                                      |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Builder

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public Builder (int adCounterKey, 
                int maxCount, 
                Duration interval)
```

<br />

<br />

|                           Parameters                           ||
|----------------|------------------------------------------------|
| `adCounterKey` | `int` <br />                                   |
| `maxCount`     | `int` <br />                                   |
| `interval`     | `Duration`: This value cannot be`null`. <br /> |

## Public methods

### build

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public KeyedFrequencyCap build ()
```

Builds and returns a[KeyedFrequencyCap](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap)instance.

<br />

|                                                                                Returns                                                                                 ||
|------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [KeyedFrequencyCap](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap) | This value cannot be`null`. <br /> |

### setAdCounterKey

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public KeyedFrequencyCap.Builder setAdCounterKey (int adCounterKey)
```

Sets the ad counter key the frequency cap applies to.

See[KeyedFrequencyCap.getAdCounterKey()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap#getAdCounterKey())for more information.

<br />

|          Parameters          ||
|----------------|--------------|
| `adCounterKey` | `int` <br /> |

|                                                                                        Returns                                                                                         ||
|----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [KeyedFrequencyCap.Builder](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder) | This value cannot be`null`. <br /> |

### setInterval

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public KeyedFrequencyCap.Builder setInterval (Duration interval)
```

Sets the interval, as a[Duration](https://developer.android.com/reference/java/time/Duration)which will be truncated to the nearest second, over which the frequency cap is calculated.

See[KeyedFrequencyCap.getInterval()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap#getInterval())for more information.

<br />

|                         Parameters                         ||
|------------|------------------------------------------------|
| `interval` | `Duration`: This value cannot be`null`. <br /> |

|                                                                                        Returns                                                                                         ||
|----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [KeyedFrequencyCap.Builder](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder) | This value cannot be`null`. <br /> |

### setMaxCount

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public KeyedFrequencyCap.Builder setMaxCount (int maxCount)
```

Sets the maximum count within the time interval for the frequency cap.

See[KeyedFrequencyCap.getMaxCount()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap#getMaxCount())for more information.

<br />

|        Parameters        ||
|------------|--------------|
| `maxCount` | `int` <br /> |

|                                                                                        Returns                                                                                         ||
|----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [KeyedFrequencyCap.Builder](https://developer.android.com/design-for-safety/privacy-sandbox/reference/adservices/common/KeyedFrequencyCap.Builder) | This value cannot be`null`. <br /> |