public class StringRegularExpression extends TypeSafeDiagnosingMatcher<java.lang.String>
Modifier | Constructor and Description |
---|---|
protected |
StringRegularExpression(java.util.regex.Pattern pattern) |
Modifier and Type | Method and Description |
---|---|
void |
describeTo(Description description)
Generates a description of the object.
|
static Matcher<java.lang.String> |
matchesRegex(java.util.regex.Pattern pattern)
Creates a matcher that checks if the examined string matches a specified
Pattern . |
static Matcher<java.lang.String> |
matchesRegex(java.lang.String regex)
Creates a matcher that checks if the examined string matches a specified regex.
|
protected boolean |
matchesSafely(java.lang.String actual,
Description mismatchDescription)
Subclasses should implement this.
|
describeMismatch, matches
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
protected StringRegularExpression(java.util.regex.Pattern pattern)
public void describeTo(Description description)
SelfDescribing
description
- The description to be built or appended to.protected boolean matchesSafely(java.lang.String actual, Description mismatchDescription)
TypeSafeDiagnosingMatcher
matchesSafely
in class TypeSafeDiagnosingMatcher<java.lang.String>
public static Matcher<java.lang.String> matchesRegex(java.util.regex.Pattern pattern)
Pattern
.
assertThat("abc", matchesRegex(Pattern.compile("ˆ[a-z]$"));
pattern
- the pattern to be used.public static Matcher<java.lang.String> matchesRegex(java.lang.String regex)
assertThat("abc", matchesRegex("ˆ[a-z]+$"));
regex
- The regex to be used for the validation.