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

org.openqa.selenium.devtools.v90.css.model.CSSStyle 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.css.model;

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

/**
 * CSS style representation.
 */
public class CSSStyle {

    private final java.util.Optional styleSheetId;

    private final java.util.List cssProperties;

    private final java.util.List shorthandEntries;

    private final java.util.Optional cssText;

    private final java.util.Optional range;

    public CSSStyle(java.util.Optional styleSheetId, java.util.List cssProperties, java.util.List shorthandEntries, java.util.Optional cssText, java.util.Optional range) {
        this.styleSheetId = styleSheetId;
        this.cssProperties = java.util.Objects.requireNonNull(cssProperties, "cssProperties is required");
        this.shorthandEntries = java.util.Objects.requireNonNull(shorthandEntries, "shorthandEntries is required");
        this.cssText = cssText;
        this.range = range;
    }

    /**
     * The css style sheet identifier (absent for user agent stylesheet and user-specified
     * stylesheet rules) this rule came from.
     */
    public java.util.Optional getStyleSheetId() {
        return styleSheetId;
    }

    /**
     * CSS properties in the style.
     */
    public java.util.List getCssProperties() {
        return cssProperties;
    }

    /**
     * Computed values for all shorthands found in the style.
     */
    public java.util.List getShorthandEntries() {
        return shorthandEntries;
    }

    /**
     * Style declaration text (if available).
     */
    public java.util.Optional getCssText() {
        return cssText;
    }

    /**
     * Style declaration range in the enclosing stylesheet (if available).
     */
    public java.util.Optional getRange() {
        return range;
    }

    private static CSSStyle fromJson(JsonInput input) {
        java.util.Optional styleSheetId = java.util.Optional.empty();
        java.util.List cssProperties = null;
        java.util.List shorthandEntries = null;
        java.util.Optional cssText = java.util.Optional.empty();
        java.util.Optional range = java.util.Optional.empty();
        input.beginObject();
        while (input.hasNext()) {
            switch(input.nextName()) {
                case "styleSheetId":
                    styleSheetId = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v90.css.model.StyleSheetId.class));
                    break;
                case "cssProperties":
                    cssProperties = input.read(new com.google.common.reflect.TypeToken>() {
                    }.getType());
                    break;
                case "shorthandEntries":
                    shorthandEntries = input.read(new com.google.common.reflect.TypeToken>() {
                    }.getType());
                    break;
                case "cssText":
                    cssText = java.util.Optional.ofNullable(input.nextString());
                    break;
                case "range":
                    range = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v90.css.model.SourceRange.class));
                    break;
                default:
                    input.skipValue();
                    break;
            }
        }
        input.endObject();
        return new CSSStyle(styleSheetId, cssProperties, shorthandEntries, cssText, range);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy