/** * Returns a composite {@link CharEscaper} instance that tries to escape * characters using a primary {@code CharEscaper} first and falls back to a * secondary one if there is no escaping. * * <p>The returned escaper will attempt to escape each character using the * primary escaper, and if the primary escaper has no escaping for that * character, it will use the secondary escaper. If the secondary escaper has * no escaping for a character either, the original character will be used. * If the primary escaper has an escape for a character, the secondary escaper * will not be used at all for that character; the escaped output of the * primary is not run through the secondary. For a case where you would like * to first escape with one escaper, and then with another, it is recommended * that you call each escaper in order. * * @param primary The primary {@code CharEscaper} to use * @param secondary The secondary {@code CharEscaper} to use if the first one * has no escaping rule for a character * @throws NullPointerException if any of the arguments is null */ public static CharEscaper fallThrough(CharEscaper primary, CharEscaper secondary) { checkNotNull(primary); checkNotNull(secondary); return new FallThroughCharEscaper(primary, secondary); }
/** * Returns a composite {@link CharEscaper} instance that tries to escape * characters using a primary {@code CharEscaper} first and falls back to a * secondary one if there is no escaping. * * <p>The returned escaper will attempt to escape each character using the * primary escaper, and if the primary escaper has no escaping for that * character, it will use the secondary escaper. If the secondary escaper has * no escaping for a character either, the original character will be used. * If the primary escaper has an escape for a character, the secondary escaper * will not be used at all for that character; the escaped output of the * primary is not run through the secondary. For a case where you would like * to first escape with one escaper, and then with another, it is recommended * that you call each escaper in order. * * @param primary The primary {@code CharEscaper} to use * @param secondary The secondary {@code CharEscaper} to use if the first one * has no escaping rule for a character * @throws NullPointerException if any of the arguments is null */ public static CharEscaper fallThrough(CharEscaper primary, CharEscaper secondary) { checkNotNull(primary); checkNotNull(secondary); return new FallThroughCharEscaper(primary, secondary); }
/** * Returns a composite {@link CharEscaper} instance that tries to escape * characters using a primary {@code CharEscaper} first and falls back to a * secondary one if there is no escaping. * * <p>The returned escaper will attempt to escape each character using the * primary escaper, and if the primary escaper has no escaping for that * character, it will use the secondary escaper. If the secondary escaper has * no escaping for a character either, the original character will be used. * If the primary escaper has an escape for a character, the secondary escaper * will not be used at all for that character; the escaped output of the * primary is not run through the secondary. For a case where you would like * to first escape with one escaper, and then with another, it is recommended * that you call each escaper in order. * * @param primary The primary {@code CharEscaper} to use * @param secondary The secondary {@code CharEscaper} to use if the first one * has no escaping rule for a character * @throws NullPointerException if any of the arguments is null */ public static CharEscaper fallThrough(CharEscaper primary, CharEscaper secondary) { checkNotNull(primary); checkNotNull(secondary); return new FallThroughCharEscaper(primary, secondary); }