types/src/main/java/com/google/common/html/types/SafeHtmlBuilder.java
public SafeHtmlBuilder setHref(SafeUrl value) {
    if (!HREF_SAFE_URL_ELEMENT_WHITELIST.contains(elementName) && !elementName.equals("link")) {
      throw new IllegalArgumentException(
          "Attribute \"href\" with a SafeUrl value can only be used "
              + "by one of the following elements: "
              + HREF_SAFE_URL_ELEMENT_WHITELIST);
    }
    if (elementName.equals("link")) {
      checkLinkDependentAttributes(attributes.get("rel"), AttributeContract.SAFE_URL);
    }
    hrefValueContract = AttributeContract.SAFE_URL;
    return setAttribute("href", value.getSafeUrlString());
  }
public SafeHtmlBuilder setHref(SafeUrl value) {
    if (!HREF_SAFE_URL_ELEMENT_WHITELIST.contains(elementName) && !elementName.equals("link")) {
      throw new IllegalArgumentException(
          "Attribute \"href\" with a SafeUrl value can only be used "
              + "by one of the following elements: "
              + HREF_SAFE_URL_ELEMENT_WHITELIST);
    }
    if (elementName.equals("link")) {
      checkLinkDependentAttributes(attributes.get("rel"), AttributeContract.SAFE_URL);
    }
    hrefValueContract = AttributeContract.SAFE_URL;
    return setAttribute("href", value.getSafeUrlString());
  }
Sets the {@code href} attribute for this element.

<p>The attribute {@code href} with a {@code SafeUrl} value is allowed on these elements:

<ul>
<li>{@code a}
<li>{@code area}
<li>{@code link}
</ul>

<p>On {@code link} elements, {@code href} may only be set to a SafeUrl value if {@code rel} is
one of the following values:

<ul>
<li>{@code alternate}
<li>{@code author}
<li>{@code bookmark}
<li>{@code canonical}
<li>{@code cite}
<li>{@code help}
<li>{@code icon}
<li>{@code license}
<li>{@code next}
<li>{@code prefetch}
<li>{@code prerender}
<li>{@code prev}
<li>{@code search}
<li>{@code subresource}
</ul>

@throws IllegalArgumentException if the {@code href} attribute with a {@code SafeUrl} value is
not allowed on this element
@throws IllegalArgumentException if this a {@code link} element and the value of {@code rel}
does not allow the SafeUrl contract on {@code href}