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

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

Introduction

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

Prototype

public static SafeHtmlProto toProto(SafeHtml safeHtml) 

Source Link

Document

Serializes a SafeHtml into its opaque protocol message representation.

Usage

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

/**
 * Converts a Soy {@link SanitizedContent} of kind HTML into a {@link SafeHtmlProto}.
 *
 * @throws IllegalStateException if this SanitizedContent's content kind is not
 *     {@link ContentKind#HTML}./*w  ww . ja  va 2s .co m*/
 */
public SafeHtmlProto toSafeHtmlProto() {
    Preconditions.checkState(getContentKind() == ContentKind.HTML,
            "toSafeHtmlProto() only valid for SanitizedContent of kind HTML, is: %s", getContentKind());
    return SafeHtmls.toProto(UncheckedConversions.safeHtmlFromStringKnownToSatisfyTypeContract(getContent()));
}