androidx.test.espresso.matcher.BoundedDiagnosingMatcher<S, T extends S>
A matcher that allows for a quick creation of a matcher that applies to a given type but only
processes items of a specific subtype of that matcher. Additional interfaces can be applied. This
class is syntactic sugar for Matchers.instanceOf(Class) where the first argument is the
base class and the remaining optional arguments are interfaces.
public BoundedDiagnosingMatcher (Class<? extends S> expectedType)
Parameters
expectedType
Class
BoundedDiagnosingMatcher
public BoundedDiagnosingMatcher (Class<? extends S> expectedType,
Class<?> interfaceType1,
Class...<?> otherInterfaces)
Parameters
expectedType
Class
interfaceType1
Class
otherInterfaces
Class
Public methods
describeMismatch
public final void describeMismatch (Object item,
Description mismatchDescription)
This method provides a default implementation for null check as well as a super type
and interface checks provided by the constructor. Failing either check provides a default
mismatch description. Passing both will call into matchesSafely(Object, Description)
which will allow the sub-class to check for a mismatch and describe what went wrong (if
anything at all).
Parameters
item
Object: The item which is assumed to have mismatched and should be described.
mismatchDescription
Description: The description builder for the mismatch.
Subclasses should implement this. The fine details of the matcher should be added to the
description. Type checking information will have already been added.
Subclasses should implement this. The item will already have been checked for the specific
type, interfaces, and will never be null.
Parameters
item
T: The pre-checked item.
mismatchDescription
Description: A Description to write to for mismatches.
Returns
boolean
true if the item matches the expectations for this Matcher.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.