public interface Matcher<T> extends SelfDescribing
A matcher over acceptable values. A matcher is able to describe itself to give feedback when it fails.
Matcher implementations should NOT directly implement this interface.
Instead, extend the
BaseMatcher abstract class,
which will ensure that the Matcher API can grow to support
new features and remain compatible with all Matcher implementations.
When using Hamcrest, there is no guarantee as to how often
describeMismatch() will be called, so the objects passed as
actual arguments should not change when referenced. If you're testing a
stream, a good practice is to collect the contents of the stream before matching.
N.B. Well designed matchers should be immutable.
|Modifier and Type||Method and Description|
Generate a description of why the matcher has not accepted the item.
Evaluates the matcher for argument item.
boolean matches(java.lang.Object actual)
actual- the object against which the matcher is evaluated.
trueif item matches, otherwise
void describeMismatch(java.lang.Object actual, Description mismatchDescription)
matches(item)is false, but will not check this.
actual- The item that the Matcher has rejected.
mismatchDescription- The description to be built or appended to.
@Deprecated void _dont_implement_Matcher___instead_extend_BaseMatcher_()
for reasons why.,