Utility class for writing one off matchers.
For example:
Matcher<String> aNonEmptyString = new CustomTypeSafeMatcher<String>("a non empty string") {
public boolean matchesSafely(String string) {
return !string.isEmpty();
}
public void describeMismatchSafely(String string, Description mismatchDescription) {
mismatchDescription.appendText("was empty");
}
};
This is a variant of
CustomMatcher
that first type checks
the argument being matched. By the time
TypeSafeMatcher.matchesSafely(T)
is
is called the argument is guaranteed to be non-null and of the correct
type.