
org.exparity.hamcrest.beans.comparators.HasPattern Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hamcrest-bean Show documentation
Show all versions of hamcrest-bean Show documentation
A Java library which provides a hamcrest matcher for matching objects and graphs which follow the Java beans standard
package org.exparity.hamcrest.beans.comparators;
import org.exparity.hamcrest.beans.TheSameAs.PropertyComparator;
/**
* Implementation of a {@link PropertyComparator} which matches a string property against a regular expression
*
* @author Stewart Bissett
*/
public class HasPattern implements PropertyComparator {
private final String regex;
public HasPattern(final String regex) {
this.regex = regex;
}
public boolean matches(final String lhs, final String rhs) {
return lhs == null ? rhs == null : rhs.matches(regex);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy