3636
3737import org .apache .commons .lang .StringEscapeUtils ;
3838
39- import com .google .common .base .Function ;
40- import com .google .common .collect .MapMaker ;
39+ import com .google .common .cache .CacheBuilder ;
40+ import com .google .common .cache .CacheLoader ;
41+ import com .google .common .cache .LoadingCache ;
4142
4243public class TextUtils {
4344 private static final String FIRSTWORD = "^([^\\ s]*).*$" ;
@@ -51,11 +52,11 @@ protected Map<String,Matcher> initialValue() {
5152 };
5253
5354 /** global soft-cache of Patterns, by string key */
54- private static final ConcurrentMap <String , Pattern > PATTERNS = new MapMaker ()
55+ private static final LoadingCache <String , Pattern > PATTERNS = CacheBuilder . newBuilder ()
5556 .concurrencyLevel (16 )
5657 .softValues ()
57- .makeComputingMap (new Function <String , Pattern >() {
58- public Pattern apply (String regex ) {
58+ .build (new CacheLoader <String , Pattern >() {
59+ public Pattern load (String regex ) {
5960 return Pattern .compile (regex );
6061 }
6162 });
@@ -84,7 +85,7 @@ public static Matcher getMatcher(String pattern, CharSequence input) {
8485 final Map <String ,Matcher > matchers = TL_MATCHER_MAP .get ();
8586 Matcher m = (Matcher )matchers .get (pattern );
8687 if (m == null ) {
87- m = PATTERNS .get (pattern ).matcher (input );
88+ m = PATTERNS .getUnchecked (pattern ).matcher (input );
8889 } else {
8990 matchers .put (pattern ,null );
9091 m .reset (input );
0 commit comments