public class IsInstanceOf extends DiagnosingMatcher<java.lang.Object>
Constructor and Description |
---|
IsInstanceOf(java.lang.Class<?> expectedClass)
Creates a new instance of IsInstanceOf
|
Modifier and Type | Method and Description |
---|---|
static <T> Matcher<T> |
any(java.lang.Class<T> type)
Creates a matcher that matches when the examined object is an instance of the specified
type ,
as determined by calling the Class.isInstance(Object) method on that type, passing the
the examined object. |
void |
describeTo(Description description)
Generates a description of the object.
|
static <T> Matcher<T> |
instanceOf(java.lang.Class<?> type)
Creates a matcher that matches when the examined object is an instance of the specified
type ,
as determined by calling the Class.isInstance(Object) method on that type, passing the
the examined object. |
protected boolean |
matches(java.lang.Object item,
Description mismatch) |
describeMismatch, matches
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString
public IsInstanceOf(java.lang.Class<?> expectedClass)
expectedClass
- The predicate evaluates to true for instances of this class
or one of its subclasses.protected boolean matches(java.lang.Object item, Description mismatch)
matches
in class DiagnosingMatcher<java.lang.Object>
public void describeTo(Description description)
SelfDescribing
description
- The description to be built or appended to.public static <T> Matcher<T> instanceOf(java.lang.Class<?> type)
type
,
as determined by calling the Class.isInstance(Object)
method on that type, passing the
the examined object.
The created matcher assumes no relationship between specified type and the examined object.
For example:assertThat(new Canoe(), instanceOf(Paddlable.class));
public static <T> Matcher<T> any(java.lang.Class<T> type)
type
,
as determined by calling the Class.isInstance(Object)
method on that type, passing the
the examined object.
The created matcher forces a relationship between specified type and the examined object, and should be
used when it is necessary to make generics conform, for example in the JMock clause
with(any(Thing.class))
assertThat(new Canoe(), instanceOf(Canoe.class));