* * *

|  [ **Overview** ](../../overview-summary.html) |  [ **Package** ](package-summary.html) |  **Class** |  [ **Use** ](class-use/CustomTypeSafeMatcher.html) |  [ **Tree** ](package-tree.html) |  [ **Deprecated** ](../../deprecated-list.html) |  [ **Index** ](../../index-all.html) |  [ **Help** ](../../help-doc.html)  
---|---|---|---|---|---|---|---  
__  
[ **PREV CLASS** ](../../org/hamcrest/CustomMatcher.html "class in org.hamcrest") [ **NEXT CLASS** ](../../org/hamcrest/Description.html "interface in org.hamcrest") |  [ **FRAMES** ](../../index.html?org/hamcrest/CustomTypeSafeMatcher.html) [ **NO FRAMES** ](CustomTypeSafeMatcher.html) [ **All Classes** ](../../allclasses-noframe.html)  
SUMMARY: NESTED | FIELD |  CONSTR  |  METHOD  |  DETAIL: FIELD |  CONSTR  |  METHOD   
  
* * *

##  org.hamcrest  
Class CustomTypeSafeMatcher<T>

    
    
    java.lang.Object
      ![extended by ](../../resources/inherit.gif)[org.hamcrest.BaseMatcher](../../org/hamcrest/BaseMatcher.html "class in org.hamcrest")<T>
          ![extended by ](../../resources/inherit.gif)[org.hamcrest.TypeSafeMatcher](../../org/hamcrest/TypeSafeMatcher.html "class in org.hamcrest")<T>
              ![extended by ](../../resources/inherit.gif)**org.hamcrest.CustomTypeSafeMatcher <T>**
    

**Type Parameters:**      ` T ` \- The type of object being matched

**All Implemented Interfaces:**      [ Matcher
](../../org/hamcrest/Matcher.html "interface in org.hamcrest") <T>, [
SelfDescribing ](../../org/hamcrest/SelfDescribing.html "interface in
org.hamcrest")

* * *
    
    
    public abstract class **CustomTypeSafeMatcher <T>**extends [TypeSafeMatcher](../../org/hamcrest/TypeSafeMatcher.html "class in org.hamcrest")<T>

Utility class for writing one off matchers. For example:

    
    
     Matcher<String> aNonEmptyString = new CustomTypeSafeMatcher<String>("a non empty string") {
       public boolean matchesSafely(String string) {
         return !string.isEmpty();
       }
       public void describeMismatchSafely(String string, Description mismatchDescription) {
         mismatchDescription.appendText("was empty");
       }
     };
     

This is a variant of [ ` CustomMatcher `
](../../org/hamcrest/CustomMatcher.html "class in org.hamcrest") that first
type checks the argument being matched. By the time [ `
TypeSafeMatcher.matchesSafely(T) `
](../../org/hamcrest/TypeSafeMatcher.html#matchesSafely\(T\)) is is called the
argument is guaranteed to be non-null and of the correct type.

**Author:**

     Neil Dunn 

* * *

**Constructor Summary**  
---  
` **[ CustomTypeSafeMatcher
](../../org/hamcrest/CustomTypeSafeMatcher.html#CustomTypeSafeMatcher\(java.lang.String\))
** (java.lang.String description) `  
  
**Method Summary**  
---  
` void ` |  ` **[ describeTo ](../../org/hamcrest/CustomTypeSafeMatcher.html#describeTo\(org.hamcrest.Description\)) ** ( [ Description ](../../org/hamcrest/Description.html "interface in org.hamcrest") description) `   
Generates a description of the object.  
**Methods inherited from class org.hamcrest.[ TypeSafeMatcher
](../../org/hamcrest/TypeSafeMatcher.html "class in org.hamcrest") **  
---  
` [ describeMismatch
](../../org/hamcrest/TypeSafeMatcher.html#describeMismatch\(java.lang.Object,
org.hamcrest.Description\)) , [ describeMismatchSafely
](../../org/hamcrest/TypeSafeMatcher.html#describeMismatchSafely\(T,
org.hamcrest.Description\)) , [ matches
](../../org/hamcrest/TypeSafeMatcher.html#matches\(java.lang.Object\)) , [
matchesSafely ](../../org/hamcrest/TypeSafeMatcher.html#matchesSafely\(T\)) `  
**Methods inherited from class org.hamcrest.[ BaseMatcher
](../../org/hamcrest/BaseMatcher.html "class in org.hamcrest") **  
---  
` [ _dont_implement_Matcher___instead_extend_BaseMatcher_
](../../org/hamcrest/BaseMatcher.html#_dont_implement_Matcher___instead_extend_BaseMatcher_\(\))
, [ toString ](../../org/hamcrest/BaseMatcher.html#toString\(\)) `  
**Methods inherited from class java.lang.Object**  
---  
` c