org.hamcrest.object
Class IsCompatibleType<T>

java.lang.Object
  extended by org.hamcrest.BaseMatcher<T>
      extended by org.hamcrest.TypeSafeMatcher<Class<?>>
          extended by org.hamcrest.object.IsCompatibleType<T>
All Implemented Interfaces:
Matcher<Class<?>>, SelfDescribing

public class IsCompatibleType<T>
extends TypeSafeMatcher<Class<?>>


Constructor Summary
IsCompatibleType(Class<T> type)
           
 
Method Summary
 void describeMismatchSafely(Class<?> cls, Description mismatchDescription)
           
 void describeTo(Description description)
           
 boolean matchesSafely(Class<?> cls)
           
static
<T> Matcher<Class<?>>
typeCompatibleWith(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(Class<T> type)
Method Detail

matchesSafely

public boolean matchesSafely(Class<?> cls)
Specified by:
matchesSafely in class TypeSafeMatcher<Class<?>>

describeMismatchSafely

public void describeMismatchSafely(Class<?> cls,
                                   Description mismatchDescription)
Overrides:
describeMismatchSafely in class TypeSafeMatcher<Class<?>>

describeTo

public void describeTo(Description description)

typeCompatibleWith

public static <T> Matcher<Class<?>> typeCompatibleWith(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


Copyright © 2014. All rights reserved.