org.hamcrest.object
Class IsCompatibleType<T>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<java.lang.Class<?>>
org.hamcrest.object.IsCompatibleType<T>
- All Implemented Interfaces:
- org.hamcrest.Matcher<java.lang.Class<?>>, org.hamcrest.SelfDescribing
public class IsCompatibleType<T>
- extends org.hamcrest.TypeSafeMatcher<java.lang.Class<?>>
Method Summary |
void |
describeMismatchSafely(java.lang.Class<?> cls,
org.hamcrest.Description mismatchDescription)
|
void |
describeTo(org.hamcrest.Description description)
|
boolean |
matchesSafely(java.lang.Class<?> cls)
|
static
<T> org.hamcrest.Matcher<java.lang.Class<?>> |
|
typeCompatibleWith(java.lang.Class<T> baseType)
Creates a matcher of Class that matches when the specified baseType is
assignable from the examined class. |
Methods inherited from class org.hamcrest.TypeSafeMatcher |
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 |
IsCompatibleType
public IsCompatibleType(java.lang.Class<T> type)
matchesSafely
public boolean matchesSafely(java.lang.Class<?> cls)
- Specified by:
matchesSafely
in class org.hamcrest.TypeSafeMatcher<java.lang.Class<?>>
describeMismatchSafely
public void describeMismatchSafely(java.lang.Class<?> cls,
org.hamcrest.Description mismatchDescription)
- Overrides:
describeMismatchSafely
in class org.hamcrest.TypeSafeMatcher<java.lang.Class<?>>
describeTo
public void describeTo(org.hamcrest.Description description)
typeCompatibleWith
public static <T> org.hamcrest.Matcher<java.lang.Class<?>> typeCompatibleWith(java.lang.Class<T> baseType)
- Creates a matcher of
Class
that matches when the specified baseType is
assignable from the examined class.
For example:
assertThat(Integer.class, typeCompatibleWith(Number.class))
- Parameters:
baseType
- the base class to examine classes against