Package org.hamcrest.object
Class HasToString<T>
- java.lang.Object
-
- org.hamcrest.BaseMatcher<T>
-
- org.hamcrest.TypeSafeDiagnosingMatcher<T>
-
- org.hamcrest.FeatureMatcher<T,java.lang.String>
-
- org.hamcrest.object.HasToString<T>
-
- All Implemented Interfaces:
Matcher<T>,SelfDescribing
public class HasToString<T> extends FeatureMatcher<T,java.lang.String>
-
-
Constructor Summary
Constructors Constructor Description HasToString(Matcher<? super java.lang.String> toStringMatcher)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringfeatureValueOf(T actual)Implement this to extract the interesting feature.static <T> Matcher<T>hasToString(java.lang.String expectedToString)Creates a matcher that matches any examined object whosetoStringmethod returns a value equalTo the specified string.static <T> Matcher<T>hasToString(Matcher<? super java.lang.String> toStringMatcher)Creates a matcher that matches any examined object whosetoStringmethod returns a value that satisfies the specified matcher.-
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_, isNotNull, toString
-
-
-
-
Constructor Detail
-
HasToString
public HasToString(Matcher<? super java.lang.String> toStringMatcher)
-
-
Method Detail
-
featureValueOf
protected java.lang.String featureValueOf(T actual)
Description copied from class:FeatureMatcherImplement this to extract the interesting feature.- Specified by:
featureValueOfin classFeatureMatcher<T,java.lang.String>- Parameters:
actual- the target object- Returns:
- the feature to be matched
-
hasToString
public static <T> Matcher<T> hasToString(Matcher<? super java.lang.String> toStringMatcher)
Creates a matcher that matches any examined object whosetoStringmethod 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> Matcher<T> hasToString(java.lang.String expectedToString)
Creates a matcher that matches any examined object whosetoStringmethod returns a value equalTo the specified string. For example:assertThat(true, hasToString("TRUE"))- Parameters:
expectedToString- the expected toString result
-
-