public abstract class

TypeSafeMatcher

extends BaseMatcher<T>
java.lang.Object
   ↳ org.hamcrest.BaseMatcher<T>
     ↳ org.junit.internal.matchers.TypeSafeMatcher<T>
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Convenient base class for Matchers that require a non-null value of a specific type. This simply implements the null check, checks the type and then casts.

Summary

Protected Constructors
TypeSafeMatcher()
TypeSafeMatcher(Class<T> expectedType)
Public Methods
final boolean matches(Object item)
Method made final to prevent accidental override.
abstract boolean matchesSafely(T item)
Subclasses should implement this.
[Expand]
Inherited Methods
From class org.hamcrest.BaseMatcher
From class java.lang.Object
From interface org.hamcrest.Matcher
From interface org.hamcrest.SelfDescribing

Protected Constructors

protected TypeSafeMatcher ()

protected TypeSafeMatcher (Class<T> expectedType)

Public Methods

public final boolean matches (Object item)

Method made final to prevent accidental override. If you need to override this, there's no point on extending TypeSafeMatcher. Instead, extend the BaseMatcher.

public abstract boolean matchesSafely (T item)

Subclasses should implement this. The item will already have been checked for the specific type and will never be null.