public class RegexpMatcher
extends org.hamcrest.BaseMatcher<java.lang.Object>
Matcher implementation that can match any object against regexp Pattern.
Any matched object is converted into a string using String.valueOf(Object) and then matched
against the pattern specified at the construction. Therefore null value will be successfully
matched against pattern string: "null".
Note: if matcher is required to match only strings, or non-null values - Matchers.allOf(Matcher...)
might be used to combine it with additional predicates.
create(String),
create(Pattern)| Modifier and Type | Method and Description |
|---|---|
static RegexpMatcher |
create(java.util.regex.Pattern pattern)
Creates new instance of the
RegexpMatcher with specified pattern. |
static RegexpMatcher |
create(java.lang.String pattern)
Creates new instance of the
RegexpMatcher with a new Pattern created from the specified string. |
void |
describeTo(org.hamcrest.Description description) |
java.util.regex.Pattern |
getPattern() |
boolean |
matches(java.lang.Object item) |
public java.util.regex.Pattern getPattern()
public boolean matches(java.lang.Object item)
public void describeTo(org.hamcrest.Description description)
public static RegexpMatcher create(java.lang.String pattern)
RegexpMatcher with a new Pattern created from the specified string.java.lang.NullPointerException - if specified string is nullcreate(Pattern)public static RegexpMatcher create(java.util.regex.Pattern pattern)
RegexpMatcher with specified pattern.java.lang.NullPointerException - if specified pattern is nullcreate(String)