UserAgentMetadata.Builder


class UserAgentMetadata.Builder


Builder used to create UserAgentMetadata objects.

Examples:

 // Create a setting with default options.
 new UserAgentMetadata.Builder().build();

 // Create a setting with a brand version contains brand name: myBrand, major version: 100,
 // full version: 100.1.1.1.
 BrandVersion brandVersion = new BrandVersion.Builder().setBrand("myBrand")
                                                       .setMajorVersion("100")
                                                       .setFullVersion("100.1.1.1")
                                                       .build();
 new UserAgentMetadata.Builder().setBrandVersionList(Collections.singletonList(brandVersion))
                                .build();

 // Create a setting brand version, platform, platform version and bitness.
 new UserAgentMetadata.Builder().setBrandVersionList(Collections.singletonList(brandVersion))
                                .setPlatform("myPlatform")
                                .setPlatform("1.1.1.1")
                                .setBitness(BITNESS_64)
                                .build();

Summary

Public constructors

Create an empty UserAgentMetadata Builder.

Create a UserAgentMetadata Builder from an existing UserAgentMetadata object.

Public functions

UserAgentMetadata

Builds the current settings into a UserAgentMetadata object.

UserAgentMetadata.Builder
setArchitecture(architecture: String?)

Sets the user-agent metadata architecture.

UserAgentMetadata.Builder
setBitness(bitness: Int)

Sets the user-agent metadata bitness, the default value is BITNESS_DEFAULT, which indicates an empty string for sec-ch-ua-bitness.

UserAgentMetadata.Builder

Sets user-agent metadata brands and their versions.

UserAgentMetadata.Builder
setFullVersion(fullVersion: String?)

Sets the user-agent metadata full version.

UserAgentMetadata.Builder
setMobile(mobile: Boolean)

Sets the user-agent metadata mobile, the default value is true.

UserAgentMetadata.Builder
setModel(model: String?)

Sets the user-agent metadata model.

UserAgentMetadata.Builder
setPlatform(platform: String?)

Sets the user-agent metadata platform.

UserAgentMetadata.Builder
setPlatformVersion(platformVersion: String?)

Sets the user-agent metadata platform version.

UserAgentMetadata.Builder
setWow64(wow64: Boolean)

Sets the user-agent metadata wow64, the default is false.

Public constructors

Builder

Added in 1.9.0
Builder()

Create an empty UserAgentMetadata Builder.

Builder

Added in 1.9.0
Builder(uaMetadata: UserAgentMetadata)

Create a UserAgentMetadata Builder from an existing UserAgentMetadata object.

Public functions

build

Added in 1.9.0
fun build(): UserAgentMetadata

Builds the current settings into a UserAgentMetadata object.

Returns
UserAgentMetadata

The UserAgentMetadata object represented by this Builder

setArchitecture

Added in 1.9.0
fun setArchitecture(architecture: String?): UserAgentMetadata.Builder

Sets the user-agent metadata architecture. If null is provided, the system default value will be used to generate the client hint.

Parameters
architecture: String?

The architecture is used to generate user-agent client hint sec-ch-ua-arch.

setBitness

Added in 1.9.0
fun setBitness(bitness: Int): UserAgentMetadata.Builder

Sets the user-agent metadata bitness, the default value is BITNESS_DEFAULT, which indicates an empty string for sec-ch-ua-bitness.

Parameters
bitness: Int

The bitness is used to generate user-agent client hint sec-ch-ua-bitness.

setBrandVersionList

Added in 1.9.0
fun setBrandVersionList(
    brandVersions: (Mutable)List<UserAgentMetadata.BrandVersion!>
): UserAgentMetadata.Builder

Sets user-agent metadata brands and their versions. The brand name, major version and full version should not be blank. The default value is an empty list which means the system default user-agent metadata brands and versions will be used to generate the user-agent client hints.

Parameters
brandVersions: (Mutable)List<UserAgentMetadata.BrandVersion!>

a list of BrandVersion used to generated user-agent client hints sec-cu-ua and sec-ch-ua-full-version-list.

setFullVersion

Added in 1.9.0
fun setFullVersion(fullVersion: String?): UserAgentMetadata.Builder

Sets the user-agent metadata full version. The full version should not be blank, even though the spec about brand full version could be empty. A blank full version could cause inconsistent brands when generating brand version related user-agent client hints. It also provides a bad experience for developers when processing the brand full version. If null is provided, the system default value will be used to generate the client hint.

Parameters
fullVersion: String?

The full version is used to generate user-agent client hint sec-ch-ua-full-version.

setMobile

Added in 1.9.0
fun setMobile(mobile: Boolean): UserAgentMetadata.Builder

Sets the user-agent metadata mobile, the default value is true.

Parameters
mobile: Boolean

The mobile is used to generate user-agent client hint sec-ch-ua-mobile.

setModel

Added in 1.9.0
fun setModel(model: String?): UserAgentMetadata.Builder

Sets the user-agent metadata model. If null is provided, the system default value will be used to generate the client hint.

Parameters
model: String?

The model is used to generate user-agent client hint sec-ch-ua-model.

setPlatform

Added in 1.9.0
fun setPlatform(platform: String?): UserAgentMetadata.Builder

Sets the user-agent metadata platform. The platform should not be blank. If null is provided, the system default value will be used to generate the client hint.

Parameters
platform: String?

The platform is used to generate user-agent client hint sec-ch-ua-platform.

setPlatformVersion

Added in 1.9.0
fun setPlatformVersion(platformVersion: String?): UserAgentMetadata.Builder

Sets the user-agent metadata platform version. If null is provided, the system default value will be used to generate the client hint.

Parameters
platformVersion: String?

The platform version is used to generate user-agent client hint sec-ch-ua-platform-version.

setWow64

Added in 1.9.0
fun setWow64(wow64: Boolean): UserAgentMetadata.Builder

Sets the user-agent metadata wow64, the default is false.

Parameters
wow64: Boolean

The wow64 is used to generate user-agent client hint sec-ch-ua-wow64.