This repository was archived by the owner on May 14, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
src/main/java/com/google/api/generator/engine/escaper Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818import com .google .common .escape .Escapers ;
1919
2020public class MetacharEscaper extends Escaper {
21+ private static final MetacharEscaper SINGLETON = new MetacharEscaper ();
22+
2123 // Handle escape characters (https://docs.oracle.com/javase/tutorial/java/data/characters.html)
2224 // for the comments here, else JavaFormmater cannot properly format the string comment.
2325 // `"` and `'` are overlooked because the comments will not be surrounded by `"` or `'`.
24- private static final Escaper escaper =
26+ private static final Escaper charEscaper =
2527 Escapers .builder ()
2628 .addEscape ('\t' , "\\ t" )
2729 .addEscape ('\b' , "\\ b" )
@@ -35,10 +37,10 @@ private MetacharEscaper() {}
3537
3638 @ Override
3739 public String escape (String sourceString ) {
38- return escaper .escape (sourceString );
40+ return charEscaper .escape (sourceString );
3941 }
4042
4143 public static String escaper (String source ) {
42- return new MetacharEscaper () .escape (source );
44+ return SINGLETON .escape (source );
4345 }
4446}
You can’t perform that action at this time.
0 commit comments