1 package org.pojomatic.internal;
2
3 import org.hamcrest.Description;
4 import org.hamcrest.TypeSafeMatcher;
5
6 public class RegexMatcher extends TypeSafeMatcher<String> {
7 private final String regex;
8
9 public RegexMatcher(String regex){
10 this.regex = regex;
11 }
12
13 public static RegexMatcher matches(String regex){
14 return new RegexMatcher(regex);
15 }
16
17 @Override
18 public void describeTo(Description description){
19 description.appendText("matches regex=").appendText(regex);
20 }
21
22 @Override
23 protected boolean matchesSafely(String item) {
24 return item.matches(regex);
25 }
26 }