1
1
package org .hamcrest .object ;
2
2
3
+ import org .hamcrest .FeatureMatcher ;
3
4
import org .hamcrest .Matcher ;
4
5
import org .hamcrest .collection .IsIn ;
5
6
import org .hamcrest .comparator .ComparatorMatcherBuilder ;
@@ -134,6 +135,7 @@ public static Matcher<Object> nullValue() {
134
135
*
135
136
* @param type dummy parameter used to infer the generic type of the returned matcher
136
137
*/
138
+ @ SuppressWarnings ("UnusedParameters" )
137
139
public static <T > Matcher <T > nullValue (Class <T > type ) {
138
140
return new IsNull <>();
139
141
}
@@ -264,9 +266,10 @@ public static <T extends Comparable<? super T>> Matcher<T> lessThanOrEqualTo(T v
264
266
* @param toStringMatcher the matcher used to verify the toString result
265
267
*/
266
268
public static <T > Matcher <T > hasToString (org .hamcrest .Matcher <? super String > toStringMatcher ) {
267
- return org .hamcrest .object .HasToString .hasToString (toStringMatcher );
269
+ return new FeatureMatcher <T , String >(toStringMatcher , "with toString()" , "toString()" ) {
270
+ @ Override protected String featureValueOf (T actual ) { return String .valueOf (actual ); }
271
+ };
268
272
}
269
-
270
273
/**
271
274
* Creates a matcher that matches any examined object whose <code>toString</code> method
272
275
* returns a value equalTo the specified string.
@@ -276,7 +279,7 @@ public static <T> Matcher<T> hasToString(org.hamcrest.Matcher<? super String> to
276
279
* @param expectedToString the expected toString result
277
280
*/
278
281
public static <T > Matcher <T > hasToString (String expectedToString ) {
279
- return org . hamcrest . object . HasToString . hasToString (expectedToString );
282
+ return hasToString (equalTo ( expectedToString ) );
280
283
}
281
284
282
285
/**
0 commit comments