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.
N.B. Well designed matchers should be immutable.
BaseMatcher
Modifier and Type | Method and Description |
---|---|
void |
_dont_implement_Matcher___instead_extend_BaseMatcher_()
Deprecated.
to make
|
void |
describeMismatch(java.lang.Object item,
Description mismatchDescription)
Generate a description of why the matcher has not accepted the item.
|
boolean |
matches(java.lang.Object item)
Evaluates the matcher for argument item.
|
describeTo
boolean matches(java.lang.Object item)
item
- the object against which the matcher is evaluated.true
if item matches, otherwise false
.BaseMatcher
void describeMismatch(java.lang.Object item, Description mismatchDescription)
matches(item)
is false, but
will not check this.item
- 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.
,
BaseMatcher