matchesSafely().
| Modifier and Type | Field and Description |
|---|---|
| private final Class | |
| private static final ReflectiveTypeFinder |
| Access | Constructor and Description |
|---|---|
| protected | TypeSafeDiagnosingMatcher(Class<?>
The expectedType of the actual value. expectedType)Use this constructor if the subclass that implements |
| protected | TypeSafeDiagnosingMatcher(ReflectiveTypeFinder
A type finder to extract the type typeFinder)Use this constructor if the subclass that implements |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public final void | describeMismatch(Object
The item that the Matcher has rejected. item, Description The description to be built or appended to. mismatchDescription)Overrides org. Implements org. |
| public final boolean | matches(Object
the object against which the matcher is evaluated. item)Implements org. |
| protected abstract boolean |
| expectedType | back to summary |
|---|---|
| private final Class<?> expectedType | |
| TYPE_FINDER | back to summary |
|---|---|
| private static final ReflectiveTypeFinder TYPE_FINDER | |
| TypeSafeDiagnosingMatcher | back to summary |
|---|---|
| protected TypeSafeDiagnosingMatcher(Class<?> expectedType) Use this constructor if the subclass that implements
| |
| TypeSafeDiagnosingMatcher | back to summary |
|---|---|
| protected TypeSafeDiagnosingMatcher(ReflectiveTypeFinder typeFinder) Use this constructor if the subclass that implements
| |
| TypeSafeDiagnosingMatcher | back to summary |
|---|---|
| protected TypeSafeDiagnosingMatcher() The default constructor for simple sub types | |
| describeMismatch | back to summary |
|---|---|
| public final void describeMismatch(Object item, Description mismatchDescription) Overrides org. Implements org. Doc from org. 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 final boolean matches(Object item) Implements org. Doc from org. 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.
| |
| matchesSafely | back to summary |
|---|---|
| protected abstract boolean matchesSafely(T item, Description mismatchDescription) Subclasses should implement this. The item will already have been checked for the specific type and will never be null. | |