Example usage for com.google.common.html.types SafeStyleSheets toProto

List of usage examples for com.google.common.html.types SafeStyleSheets toProto

Introduction

In this page you can find the example usage for com.google.common.html.types SafeStyleSheets toProto.

Prototype

public static SafeStyleSheetProto toProto(SafeStyleSheet style) 

Source Link

Document

Serializes a SafeStyleSheet into its opaque protocol message representation.

Usage

From source file:com.google.template.soy.data.SanitizedContent.java

/**
 * Converts a Soy {@link SanitizedContent} of kind CSS into a {@link SafeStyleSheetProto}.
 *
 * <p>To ensure correct behavior and usage, the SanitizedContent object should fulfill the
 * contract of SafeStyleSheet - the CSS content should represent the top-level content of a style
 * element within HTML.//from  ww w. ja  va 2s . c  om
 *
 * @throws IllegalStateException if this SanitizedContent's content kind is not
 *     {@link ContentKind#CSS}.
 */
public SafeStyleSheetProto toSafeStyleSheetProto() {
    Preconditions.checkState(getContentKind() == ContentKind.CSS,
            "toSafeStyleSheetProto() only valid for SanitizedContent of kind CSS, is: %s", getContentKind());
    return SafeStyleSheets.toProto(toSafeStyleSheet());
}