package geniusweb.issuevalue; import org.hamcrest.Description; import org.hamcrest.Matcher; public class PatternMatch implements Matcher { private String regex; public PatternMatch(String regex) { this.regex = regex; } @Override public void describeTo(Description description) { description.appendText("'" + regex + "'"); } @Override public boolean matches(Object item) { if (!(item instanceof String)) throw new IllegalArgumentException( "item is not a string:" + item.toString()); return ((String) item).matches(regex); } @Override public void describeMismatch(Object text, Description mismatchDescription) { mismatchDescription.appendText("'" + text + "' does not match regular expression '" + regex + "'"); } @Override public void _dont_implement_Matcher___instead_extend_BaseMatcher_() { } }