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.
For easy access to common Matcher implementations, use the static factory
methods in CoreMatchers.
N.B. Well designed matchers should be immutable.
CoreMatchers, BaseMatcher
| Modifier and Type | Method and Description |
|---|---|
| public void | _dont_implement_Matcher___instead_extend_BaseMatcher_()
Deprecated
to make
This method simply acts a friendly reminder not to implement Matcher directly and
instead extend BaseMatcher.
|
| public void | describeMismatch(Object
The item that the Matcher has rejected. item, Description The description to be built or appended to. mismatchDescription)Generate a description of why the matcher has not accepted the item. |
| public boolean |
| _dont_implement_Matcher___instead_extend_BaseMatcher_ | back to summary |
|---|---|
| public void _dont_implement_Matcher___instead_extend_BaseMatcher_()
Deprecated to make This method simply acts a friendly reminder not to implement Matcher directly and instead extend BaseMatcher. It's easy to ignore JavaDoc, but a bit harder to ignore compile errors .
| |
| describeMismatch | back to summary |
|---|---|
| public void describeMismatch(Object item, Description mismatchDescription) Generate a description of why the matcher has not accepted the item.
The description will be part of a larger description of why a matching
failed, so it should be concise.
This method assumes that
| |
| matches | back to summary |
|---|---|
| public boolean matches(Object item) Evaluates the matcher for argument item. This method matches against Object, instead of the generic type T. This is because the caller of the Matcher does not know at runtime what the type is (because of type erasure with Java generics). It is down to the implementations to check the correct type.
| |