org.hamcrest.object
Class HasToString<T>

java.lang.Object
  extended by org.hamcrest.BaseMatcher<T>
      extended by org.hamcrest.TypeSafeDiagnosingMatcher<T>
          extended by org.hamcrest.FeatureMatcher<T,java.lang.String>
              extended by org.hamcrest.object.HasToString<T>
All Implemented Interfaces:
org.hamcrest.Matcher<T>, org.hamcrest.SelfDescribing

public class HasToString<T>
extends org.hamcrest.FeatureMatcher<T,java.lang.String>


Constructor Summary
HasToString(org.hamcrest.Matcher<? super java.lang.String> toStringMatcher)
           
 
Method Summary
protected  java.lang.String featureValueOf(T actual)
           
static
<T> org.hamcrest.Matcher<T>
hasToString(org.hamcrest.Matcher<? super java.lang.String> toStringMatcher)
          Creates a matcher that matches any examined object whose toString method returns a value that satisfies the specified matcher.
static
<T> org.hamcrest.Matcher<T>
hasToString(java.lang.String expectedToString)
          Creates a matcher that matches any examined object whose toString method returns a value equalTo the specified string.
 
Methods inherited from class org.hamcrest.FeatureMatcher
describeTo, matchesSafely
 
Methods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher
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

HasToString

public HasToString(org.hamcrest.Matcher<? super java.lang.String> toStringMatcher)
Method Detail

featureValueOf

protected java.lang.String featureValueOf(T actual)
Specified by:
featureValueOf in class org.hamcrest.FeatureMatcher<T,java.lang.String>

hasToString

public static <T> org.hamcrest.Matcher<T> hasToString(org.hamcrest.Matcher<? super java.lang.String> toStringMatcher)
Creates a matcher that matches any examined object whose toString method returns a value that satisfies the specified matcher.

For example:

assertThat(true, hasToString(equalTo("TRUE")))

Parameters:
toStringMatcher - the matcher used to verify the toString result

hasToString

public static <T> org.hamcrest.Matcher<T> hasToString(java.lang.String expectedToString)
Creates a matcher that matches any examined object whose toString method returns a value equalTo the specified string.

For example:

assertThat(true, hasToString("TRUE"))

Parameters:
expectedToString - the expected toString result