guava/src/com/google/common/escape/Escapers.java
static UnicodeEscaper asUnicodeEscaper(Escaper escaper) {
    checkNotNull(escaper);
    if (escaper instanceof UnicodeEscaper) {
      return (UnicodeEscaper) escaper;
    } else if (escaper instanceof CharEscaper) {
      return wrap((CharEscaper) escaper);
    }
    // In practice this shouldn't happen because it would be very odd not to
    // extend either CharEscaper or UnicodeEscaper for non trivial cases.
    throw new IllegalArgumentException(
        "Cannot create a UnicodeEscaper from: " + escaper.getClass().getName());
  }
static UnicodeEscaper asUnicodeEscaper(Escaper escaper) {
    checkNotNull(escaper);
    if (escaper instanceof UnicodeEscaper) {
      return (UnicodeEscaper) escaper;
    } else if (escaper instanceof CharEscaper) {
      return wrap((CharEscaper) escaper);
    }
    // In practice this shouldn't happen because it would be very odd not to
    // extend either CharEscaper or UnicodeEscaper for non trivial cases.
    throw new IllegalArgumentException(
        "Cannot create a UnicodeEscaper from: " + escaper.getClass().getName());
  }
Returns a {@link UnicodeEscaper} equivalent to the given escaper instance. If the escaper is
already a UnicodeEscaper then it is simply returned, otherwise it is wrapped in a
UnicodeEscaper.

<p>When a {@link CharEscaper} escaper is wrapped by this method it acquires extra behavior with
respect to the well-formedness of Unicode character sequences and will throw {@link
IllegalArgumentException} when given bad input.

@param escaper the instance to be wrapped
@return a UnicodeEscaper with the same behavior as the given instance
@throws NullPointerException if escaper is null
@throws IllegalArgumentException if escaper is not a UnicodeEscaper or a CharEscaper