org.hamcrest.object
Class IsCompatibleType<T>

java.lang.Object
  extended by org.hamcrest.BaseMatcher<T>
      extended by org.hamcrest.TypeSafeMatcher<java.lang.Class<?>>
          extended by 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<?>>


Constructor Summary
IsCompatibleType(java.lang.Class<T> type)
           
 
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
 

Constructor Detail

IsCompatibleType

public IsCompatibleType(java.lang.Class<T> type)
Method Detail

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