KeyedFrequencyCap

public final class KeyedFrequencyCap
extends Object implements Parcelable

java.lang.Object
   ↳ android.adservices.common.KeyedFrequencyCap


A frequency cap for a specific ad counter key.

Frequency caps define the maximum rate an event can occur within a given time interval. If the frequency cap is exceeded, the associated ad will be filtered out of ad selection.

Summary

Nested classes

class KeyedFrequencyCap.Builder

Builder for creating KeyedFrequencyCap objects. 

Inherited constants

Fields

public static final Creator<KeyedFrequencyCap> CREATOR

Public methods

boolean equals(Object o)

Checks whether the KeyedFrequencyCap objects contain the same information.

int getAdCounterKey()

Returns the ad counter key that the frequency cap is applied to.

Duration getInterval()

Returns the interval, as a Duration which will be truncated to the nearest second, over which the frequency cap is calculated.

int getMaxCount()

Returns the maximum count of event occurrences allowed within a given time interval.

int hashCode()

Returns the hash of the KeyedFrequencyCap object's data.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Fields

Public methods

equals

public boolean equals (Object o)

Checks whether the KeyedFrequencyCap objects contain the same information.

Parameters
o Object: the reference object with which to compare.

Returns
boolean true if this object is the same as the obj argument; false otherwise.

getAdCounterKey

public int getAdCounterKey ()

Returns the ad counter key that the frequency cap is applied to.

The ad counter key is defined by an adtech and is an arbitrary numeric identifier which defines any criteria which may have previously been counted and persisted on the device. If the on-device count exceeds the maximum count within a certain time interval, the frequency cap has been exceeded.

Returns
int This value cannot be null.

getInterval

public Duration getInterval ()

Returns the interval, as a Duration which will be truncated to the nearest second, over which the frequency cap is calculated.

When this frequency cap is computed, the number of persisted events is counted in the most recent time interval. If the count of previously occurring matching events for an adtech is greater than the number returned by getMaxCount(), the frequency cap has been exceeded, and the ad will not be eligible for ad selection.

Returns
Duration This value cannot be null.

getMaxCount

public int getMaxCount ()

Returns the maximum count of event occurrences allowed within a given time interval.

If there are more events matching the ad counter key and ad event type counted on the device within the time interval defined by getInterval(), the frequency cap has been exceeded, and the ad will not be eligible for ad selection.

For example, an ad that specifies a filter for a max count of two within one hour will not be eligible for ad selection if the event has been counted two or more times within the hour preceding the ad selection process.

Returns
int

hashCode

public int hashCode ()

Returns the hash of the KeyedFrequencyCap object's data.

Returns
int a hash code value for this object.

toString

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES