org.onap migration
[vid.git] / vid-app-common / src / test / java / org / onap / vid / testUtils / RegExMatcher.java
1 package org.onap.vid.testUtils;
2
3 import org.hamcrest.Description;
4 import org.hamcrest.TypeSafeMatcher;
5
6 public class RegExMatcher extends TypeSafeMatcher<String> {
7
8     private final String regEx;
9
10     public RegExMatcher(String regEx) {
11         this.regEx = regEx;
12     }
13
14
15     @Override
16     public void describeTo(Description description) {
17         description.appendText("matches regEx="+regEx);
18     }
19
20
21     @Override
22     protected boolean matchesSafely(String item) {
23         return item.matches(regEx);
24     }
25
26     public static RegExMatcher matchesRegEx(final String regEx) {
27         return new RegExMatcher(regEx);
28     }
29 }