All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openqa.selenium.devtools.v90.emulation.model.UserAgentMetadata Maven / Gradle / Ivy

Go to download

Selenium automates browsers. That's it! What you do with that power is entirely up to you.

There is a newer version: 4.0.0-beta-4
Show newest version
package org.openqa.selenium.devtools.v90.emulation.model;

import org.openqa.selenium.Beta;
import org.openqa.selenium.json.JsonInput;

/**
 * Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints
 * Missing optional values will be filled in by the target with what it would normally use.
 */
@org.openqa.selenium.Beta()
public class UserAgentMetadata {

    private final java.util.Optional> brands;

    private final java.util.Optional fullVersion;

    private final java.lang.String platform;

    private final java.lang.String platformVersion;

    private final java.lang.String architecture;

    private final java.lang.String model;

    private final java.lang.Boolean mobile;

    public UserAgentMetadata(java.util.Optional> brands, java.util.Optional fullVersion, java.lang.String platform, java.lang.String platformVersion, java.lang.String architecture, java.lang.String model, java.lang.Boolean mobile) {
        this.brands = brands;
        this.fullVersion = fullVersion;
        this.platform = java.util.Objects.requireNonNull(platform, "platform is required");
        this.platformVersion = java.util.Objects.requireNonNull(platformVersion, "platformVersion is required");
        this.architecture = java.util.Objects.requireNonNull(architecture, "architecture is required");
        this.model = java.util.Objects.requireNonNull(model, "model is required");
        this.mobile = java.util.Objects.requireNonNull(mobile, "mobile is required");
    }

    public java.util.Optional> getBrands() {
        return brands;
    }

    public java.util.Optional getFullVersion() {
        return fullVersion;
    }

    public java.lang.String getPlatform() {
        return platform;
    }

    public java.lang.String getPlatformVersion() {
        return platformVersion;
    }

    public java.lang.String getArchitecture() {
        return architecture;
    }

    public java.lang.String getModel() {
        return model;
    }

    public java.lang.Boolean getMobile() {
        return mobile;
    }

    private static UserAgentMetadata fromJson(JsonInput input) {
        java.util.Optional> brands = java.util.Optional.empty();
        java.util.Optional fullVersion = java.util.Optional.empty();
        java.lang.String platform = null;
        java.lang.String platformVersion = null;
        java.lang.String architecture = null;
        java.lang.String model = null;
        java.lang.Boolean mobile = false;
        input.beginObject();
        while (input.hasNext()) {
            switch(input.nextName()) {
                case "brands":
                    brands = java.util.Optional.ofNullable(input.read(new com.google.common.reflect.TypeToken>() {
                    }.getType()));
                    break;
                case "fullVersion":
                    fullVersion = java.util.Optional.ofNullable(input.nextString());
                    break;
                case "platform":
                    platform = input.nextString();
                    break;
                case "platformVersion":
                    platformVersion = input.nextString();
                    break;
                case "architecture":
                    architecture = input.nextString();
                    break;
                case "model":
                    model = input.nextString();
                    break;
                case "mobile":
                    mobile = input.nextBoolean();
                    break;
                default:
                    input.skipValue();
                    break;
            }
        }
        input.endObject();
        return new UserAgentMetadata(brands, fullVersion, platform, platformVersion, architecture, model, mobile);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy