com.pivotallabs.greatexpectations.matchers.StringMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of great-expectations Show documentation
Show all versions of great-expectations Show documentation
Jasmine-style expect() for Java.
The newest version!
package com.pivotallabs.greatexpectations.matchers;
import com.pivotallabs.greatexpectations.MatcherOf;
import java.util.regex.Pattern;
@MatcherOf(String.class)
public class StringMatcher> extends ObjectMatcher {
public boolean toContain(String expected) {
return actual.indexOf(expected) != -1;
}
public boolean toStartWith(String expected) {
return actual.startsWith(expected);
}
public boolean toEndWith(String expected) {
return actual.endsWith(expected);
}
public boolean toMatch(String expectedPattern) {
return Pattern.compile(expectedPattern).matcher(actual).find();
}
// public boolean toEqual(String expected) {
// if (!GreatExpectations.equalsSafely(expected, actual) && !inverted) {
// GreatExpectations.lastExpectTrace = null;
// throw new ComparisonFailure("Expected strings to be equal to each other", expected, actual); // Shows friendly diff
// }
// return actual.equals(expected);
// }
}