11package org .hamcrest .collection ;
22
3+ import org .hamcrest .Matcher ;
4+
5+ import java .util .Map ;
6+
7+ import static org .hamcrest .core .IsEqual .equalTo ;
8+
39public class MatchingMaps {
410 /**
511 * Creates a matcher for {@link java.util.Map}s that matches when the <code>size()</code> method returns
@@ -9,8 +15,8 @@ public class MatchingMaps {
915 *
1016 * @param sizeMatcher a matcher for the size of an examined {@link java.util.Map}
1117 */
12- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> aMapWithSize (org . hamcrest . Matcher <? super java . lang . Integer > sizeMatcher ) {
13- return org . hamcrest . collection . IsMapWithSize . aMapWithSize (sizeMatcher );
18+ public static <K , V > Matcher <Map <? extends K , ? extends V >> aMapWithSize (Matcher <? super Integer > sizeMatcher ) {
19+ return new IsMapWithSize <> (sizeMatcher );
1420 }
1521
1622 /**
@@ -21,8 +27,8 @@ public class MatchingMaps {
2127 *
2228 * @param size the expected size of an examined {@link java.util.Map}
2329 */
24- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> aMapWithSize (int size ) {
25- return org . hamcrest . collection . IsMapWithSize . aMapWithSize (size );
30+ public static <K , V > Matcher <Map <? extends K , ? extends V >> aMapWithSize (int size ) {
31+ return aMapWithSize (equalTo ( size ) );
2632 }
2733
2834 /**
@@ -31,8 +37,8 @@ public class MatchingMaps {
3137 * For example:
3238 * <pre>assertThat(myMap, is(anEmptyMap()))</pre>
3339 */
34- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> anEmptyMap () {
35- return org . hamcrest . collection . IsMapWithSize . anEmptyMap ( );
40+ public static <K , V > Matcher <Map <? extends K , ? extends V >> anEmptyMap () {
41+ return aMapWithSize ( equalTo ( 0 ) );
3642 }
3743
3844 /**
@@ -45,8 +51,8 @@ public class MatchingMaps {
4551 * @param keyMatcher the key matcher that, in combination with the valueMatcher, must be satisfied by at least one entry
4652 * @param valueMatcher the value matcher that, in combination with the keyMatcher, must be satisfied by at least one entry
4753 */
48- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> hasEntry (org . hamcrest . Matcher <? super K > keyMatcher , org . hamcrest . Matcher <? super V > valueMatcher ) {
49- return org . hamcrest . collection . IsMapContaining .hasEntry (keyMatcher , valueMatcher );
54+ public static <K , V > Matcher <Map <? extends K , ? extends V >> hasEntry (Matcher <? super K > keyMatcher , Matcher <? super V > valueMatcher ) {
55+ return IsMapContaining .hasEntry (keyMatcher , valueMatcher );
5056 }
5157
5258 /**
@@ -59,8 +65,8 @@ public class MatchingMaps {
5965 * @param key the key that, in combination with the value, must be describe at least one entry
6066 * @param value the value that, in combination with the key, must be describe at least one entry
6167 */
62- public static <K , V > org . hamcrest . Matcher <java . util . Map <? extends K , ? extends V >> hasEntry (K key , V value ) {
63- return org . hamcrest . collection . IsMapContaining .hasEntry (key , value );
68+ public static <K , V > Matcher <Map <? extends K , ? extends V >> hasEntry (K key , V value ) {
69+ return IsMapContaining .hasEntry (key , value );
6470 }
6571
6672 /**
@@ -71,8 +77,8 @@ public class MatchingMaps {
7177 *
7278 * @param keyMatcher the matcher that must be satisfied by at least one key
7379 */
74- public static <K > org .hamcrest .Matcher <java . util . Map <? extends K , ?>> hasKey (org . hamcrest . Matcher <? super K > keyMatcher ) {
75- return org . hamcrest . collection . IsMapContaining .hasKey (keyMatcher );
80+ public static <K > org .hamcrest .Matcher <Map <? extends K , ?>> hasKey (Matcher <? super K > keyMatcher ) {
81+ return IsMapContaining .hasKey (keyMatcher );
7682 }
7783
7884 /**
@@ -83,8 +89,8 @@ public class MatchingMaps {
8389 *
8490 * @param key the key that satisfying maps must contain
8591 */
86- public static <K > org .hamcrest .Matcher <java . util . Map <? extends K , ?>> hasKey (K key ) {
87- return org . hamcrest . collection . IsMapContaining .hasKey (key );
92+ public static <K > org .hamcrest .Matcher <Map <? extends K , ?>> hasKey (K key ) {
93+ return IsMapContaining .hasKey (key );
8894 }
8995
9096 /**
@@ -95,8 +101,8 @@ public class MatchingMaps {
95101 *
96102 * @param valueMatcher the matcher that must be satisfied by at least one value
97103 */
98- public static <V > org .hamcrest .Matcher <java . util . Map <?, ? extends V >> hasValue (org . hamcrest . Matcher <? super V > valueMatcher ) {
99- return org . hamcrest . collection . IsMapContaining .hasValue (valueMatcher );
104+ public static <V > org .hamcrest .Matcher <Map <?, ? extends V >> hasValue (Matcher <? super V > valueMatcher ) {
105+ return IsMapContaining .hasValue (valueMatcher );
100106 }
101107
102108 /**
@@ -107,8 +113,8 @@ public class MatchingMaps {
107113 *
108114 * @param value the value that satisfying maps must contain
109115 */
110- public static <V > org .hamcrest .Matcher <java . util . Map <?, ? extends V >> hasValue (V value ) {
111- return org . hamcrest . collection . IsMapContaining .hasValue (value );
116+ public static <V > org .hamcrest .Matcher <Map <?, ? extends V >> hasValue (V value ) {
117+ return IsMapContaining .hasValue (value );
112118 }
113119
114120}
0 commit comments