types/src/main/java/com/google/common/html/types/SafeStyles.java
public static SafeStyle fromConstant(@CompileTimeConstant final String style) {
    if (style.length() == 0) {
      return SafeStyle.EMPTY;
    }
    for (int i = 0; i < style.length(); i++) {
      if (style.charAt(i) == '<' || style.charAt(i) == '>') {
        throw new IllegalArgumentException("Forbidden characters in style string: " + style);
      }
    }
    if (style.charAt(style.length() - 1) != ';') {
      throw new IllegalArgumentException("Last character of style string is not ';': " + style);
    }
    if (!style.contains(":")) {
      throw new IllegalArgumentException("Style string must contain at least one ':', to "
        + "specify a \"name: value\" pair: " + style);
    }
    return create(style);
  }
public static SafeStyle fromConstant(@CompileTimeConstant final String style) {
    if (style.length() == 0) {
      return SafeStyle.EMPTY;
    }
    for (int i = 0; i < style.length(); i++) {
      if (style.charAt(i) == '<' || style.charAt(i) == '>') {
        throw new IllegalArgumentException("Forbidden characters in style string: " + style);
      }
    }
    if (style.charAt(style.length() - 1) != ';') {
      throw new IllegalArgumentException("Last character of style string is not ';': " + style);
    }
    if (!style.contains(":")) {
      throw new IllegalArgumentException("Style string must contain at least one ':', to "
        + "specify a \"name: value\" pair: " + style);
    }
    return create(style);
  }
Creates a SafeStyle from the given compile-time constant string {@code style}.

<p>{@code style} should be in the format {@code name: value; [name: value; ...]} and must
not have any &lt; or &gt; characters in it. This is so that SafeStyle's contract is preserved,
allowing the SafeStyle to correctly be interpreted as a sequence of CSS declarations and
without affecting the syntactic structure of any surrounding CSS and HTML.

<p>This method performs basic sanity checks on the format of {@code style} but does not
constrain the format of {@code name} and {@code value}, except for disallowing tag characters.

@throws IllegalArgumentException if some of the constraints of the format specified above
are not met