/** * Creates a {@link SafeHtmlProto} wrapping the given {@code string}. No validation is performed. * * <p>If possible please use the production API in * {@link com.google.common.html.types.SafeHtmls} * instead. */ public static SafeHtmlProto newSafeHtmlProtoForTest(String string) { return SafeHtmls.toProto(newSafeHtmlForTest(string)); }
/** * 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}. */ 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())); }
/** * 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}. */ 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())); }