org.hamcrest.core.SubstringMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-curves4 Show documentation
Show all versions of virtdata-lib-curves4 Show documentation
Statistical sampling library for use in virtualdataset libraries, based on apache commons math 4
package org.hamcrest.core;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
public abstract class SubstringMatcher extends TypeSafeMatcher {
// TODO: Replace String with CharSequence to allow for easy interopability between
// String, StringBuffer, StringBuilder, CharBuffer, etc (joe).
protected final String substring;
protected SubstringMatcher(final String substring) {
this.substring = substring;
}
@Override
public boolean matchesSafely(String item) {
return evalSubstringOf(item);
}
@Override
public void describeMismatchSafely(String item, Description mismatchDescription) {
mismatchDescription.appendText("was \"").appendText(item).appendText("\"");
}
@Override
public void describeTo(Description description) {
description.appendText("a string ")
.appendText(relationship())
.appendText(" ")
.appendValue(substring);
}
protected abstract boolean evalSubstringOf(String string);
protected abstract String relationship();
}