
org.whaka.asserts.matcher.RegexpMatcher Maven / Gradle / Ivy
package org.whaka.asserts.matcher;
import static java.util.Objects.*;
import java.util.regex.Pattern;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
/**
* {@link Matcher} implementation that can match any object against regexp {@link Pattern}.
* Any matched object is converted into a string using {@link 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 - {@link Matchers#allOf(Matcher...)}
* might be used to combine it with additional predicates.
*
* @see #create(String)
* @see #create(Pattern)
*/
public class RegexpMatcher extends BaseMatcher
© 2015 - 2025 Weber Informatics LLC | Privacy Policy