@@ -125,43 +125,7 @@ private static final class SinglePredicateEvaluator extends PredicateEvaluator {
125125
126126 private static Matchers .StringMatcher fromStringMatcherProto (
127127 com .github .xds .type .matcher .v3 .StringMatcher proto ) {
128- if (proto .hasExact ()) {
129- return Matchers .StringMatcher .forExact (proto .getExact (), proto .getIgnoreCase ());
130- }
131- if (proto .hasPrefix ()) {
132- String prefix = proto .getPrefix ();
133- if (prefix .isEmpty ()) {
134- throw new IllegalArgumentException (
135- "StringMatcher prefix (match_pattern) must be non-empty" );
136- }
137- return Matchers .StringMatcher .forPrefix (prefix , proto .getIgnoreCase ());
138- }
139- if (proto .hasSuffix ()) {
140- String suffix = proto .getSuffix ();
141- if (suffix .isEmpty ()) {
142- throw new IllegalArgumentException (
143- "StringMatcher suffix (match_pattern) must be non-empty" );
144- }
145- return Matchers .StringMatcher .forSuffix (suffix , proto .getIgnoreCase ());
146- }
147- if (proto .hasContains ()) {
148- String contains = proto .getContains ();
149- if (contains .isEmpty ()) {
150- throw new IllegalArgumentException (
151- "StringMatcher contains (match_pattern) must be non-empty" );
152- }
153- return Matchers .StringMatcher .forContains (contains , proto .getIgnoreCase ());
154- }
155- if (proto .hasSafeRegex ()) {
156- String regex = proto .getSafeRegex ().getRegex ();
157- if (regex .isEmpty ()) {
158- throw new IllegalArgumentException (
159- "StringMatcher regex (match_pattern) must be non-empty" );
160- }
161- return Matchers .StringMatcher .forSafeRegEx (
162- com .google .re2j .Pattern .compile (regex ));
163- }
164- throw new IllegalArgumentException ("Unknown StringMatcher match pattern" );
128+ return io .grpc .xds .internal .MatcherParser .parseStringMatcher (proto );
165129 }
166130 }
167131
0 commit comments