/** * Creates a {@link SafeUrlProto} wrapping the given {@code string}. No validation is performed. * * <p>If possible please use the production API in * {@link com.google.common.html.types.SafeUrls} * instead. */ public static SafeUrlProto newSafeUrlProtoForTest(String string) { return SafeUrls.toProto(newSafeUrlForTest(string)); }
/** * Converts a Soy {@link SanitizedContent} of kind URI into a {@link SafeUrlProto}. * * @throws IllegalStateException if this SanitizedContent's content kind is not {@link * ContentKind#URI}. */ public SafeUrlProto toSafeUrlProto() { Preconditions.checkState( getContentKind() == ContentKind.URI, "toSafeUrlProto() only valid for SanitizedContent of kind URI, is: %s", getContentKind()); return SafeUrls.toProto( UncheckedConversions.safeUrlFromStringKnownToSatisfyTypeContract(getContent())); }
/** * Converts a Soy {@link SanitizedContent} of kind URI into a {@link SafeUrlProto}. * * @throws IllegalStateException if this SanitizedContent's content kind is not {@link * ContentKind#URI}. */ public SafeUrlProto toSafeUrlProto() { Preconditions.checkState( getContentKind() == ContentKind.URI, "toSafeUrlProto() only valid for SanitizedContent of kind URI, is: %s", getContentKind()); return SafeUrls.toProto( UncheckedConversions.safeUrlFromStringKnownToSatisfyTypeContract(getContent())); }