|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hamcrest.BaseMatcher<T> org.hamcrest.DiagnosingMatcher<Object> org.hamcrest.core.IsInstanceOf
public class IsInstanceOf
Tests whether the value is an instance of a class. Classes of basic types will be converted to the relevant "Object" classes
Constructor Summary | |
---|---|
IsInstanceOf(Class<?> expectedClass)
Creates a new instance of IsInstanceOf |
Method Summary | ||
---|---|---|
static
|
any(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
|
instanceOf(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(Object item,
Description mismatch)
|
Methods inherited from class org.hamcrest.DiagnosingMatcher |
---|
describeMismatch, matches |
Methods inherited from class org.hamcrest.BaseMatcher |
---|
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public IsInstanceOf(Class<?> expectedClass)
expectedClass
- The predicate evaluates to true for instances of this class
or one of its subclasses.Method Detail |
---|
protected boolean matches(Object item, Description mismatch)
matches
in class DiagnosingMatcher<Object>
public void describeTo(Description description)
SelfDescribing
description
- The description to be built or appended to.public static <T> Matcher<T> instanceOf(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(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));
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |