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,String>
              extended by org.hamcrest.object.HasToString<T>
All Implemented Interfaces:
Matcher<T>, SelfDescribing

public class HasToString<T>
extends FeatureMatcher<T,String>


Constructor Summary
HasToString(Matcher<? super String> toStringMatcher)
           
 
Method Summary
protected  String featureValueOf(T actual)
          Implement this to extract the interesting feature.
static
<T> Matcher<T>
hasToString(Matcher<? super String> toStringMatcher)
          Evaluates whether item.toString() satisfies a given matcher.
static
<T> Matcher<T>
hasToString(String expectedToString)
          This is a shortcut to the frequently used has_string(equalTo(x)).
 
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(Matcher<? super String> toStringMatcher)
Method Detail

featureValueOf

protected String featureValueOf(T actual)
Description copied from class: FeatureMatcher
Implement this to extract the interesting feature.

Specified by:
featureValueOf in class FeatureMatcher<T,String>
Parameters:
actual - the target object
Returns:
the feature to be matched

hasToString

public static <T> Matcher<T> hasToString(Matcher<? super String> toStringMatcher)
Evaluates whether item.toString() satisfies a given matcher.


hasToString

public static <T> Matcher<T> hasToString(String expectedToString)
This is a shortcut to the frequently used has_string(equalTo(x)). For example, assertThat(hasToString(equal_to(x))) vs. assertThat(hasToString(x))