source: java2python/geniuswebtranslator/geniuswebtest/geniusweb/issuevalue/PatternMatch.java@ 831

Last change on this file since 831 was 736, checked in by wouter, 12 months ago

fix autoboxing issues

File size: 851 bytes
Line 
1package geniusweb.issuevalue;
2
3import org.hamcrest.Description;
4import org.hamcrest.Matcher;
5
6public class PatternMatch implements Matcher<String> {
7
8 private String regex;
9
10 public PatternMatch(String regex) {
11 this.regex = regex;
12 }
13
14 @Override
15 public void describeTo(Description description) {
16 description.appendText("'" + regex + "'");
17 }
18
19 @Override
20 public boolean matches(Object item) {
21 if (!(item instanceof String))
22 throw new IllegalArgumentException(
23 "item is not a string:" + item.toString());
24 return ((String) item).matches(regex);
25 }
26
27 @Override
28 public void describeMismatch(Object text, Description mismatchDescription) {
29 mismatchDescription.appendText("'" + text
30 + "' does not match regular expression '" + regex + "'");
31 }
32
33 @Override
34 public void _dont_implement_Matcher___instead_extend_BaseMatcher_() {
35 }
36
37}
Note: See TracBrowser for help on using the repository browser.