11package org .hamcrest .collection ;
22
3+ import org .hamcrest .Matcher ;
4+
5+ import java .util .Collection ;
6+
7+ import static org .hamcrest .core .DescribedAs .describedAs ;
8+
39public class MatchArrays {
410 /**
511 * Creates a matcher that matches arrays whose elements are satisfied by the specified matchers. Matches
@@ -11,8 +17,8 @@ public class MatchArrays {
1117 * @param elementMatchers the matchers that the elements of examined arrays should satisfy
1218 */
1319 @ SafeVarargs
14- public static <T > org . hamcrest . collection . IsArray <T > array (org . hamcrest . Matcher <? super T >... elementMatchers ) {
15- return org . hamcrest . collection . IsArray .array (elementMatchers );
20+ public static <T > IsArray <T > array (Matcher <? super T >... elementMatchers ) {
21+ return IsArray .array (elementMatchers );
1622 }
1723
1824 /**
@@ -24,8 +30,8 @@ public static <T> org.hamcrest.collection.IsArray<T> array(org.hamcrest.Matcher<
2430 *
2531 * @param elementMatcher the matcher to apply to elements in examined arrays
2632 */
27- public static <T > org . hamcrest . Matcher <T []> hasItemInArray (org . hamcrest . Matcher <? super T > elementMatcher ) {
28- return org . hamcrest . collection . IsArrayContaining .hasItemInArray (elementMatcher );
33+ public static <T > Matcher <T []> hasItemInArray (Matcher <? super T > elementMatcher ) {
34+ return IsArrayContaining .hasItemInArray (elementMatcher );
2935 }
3036
3137 /**
@@ -37,8 +43,8 @@ public static <T> org.hamcrest.Matcher<T[]> hasItemInArray(org.hamcrest.Matcher<
3743 *
3844 * @param element the element that should be present in examined arrays
3945 */
40- public static <T > org . hamcrest . Matcher <T []> hasItemInArray (T element ) {
41- return org . hamcrest . collection . IsArrayContaining .hasItemInArray (element );
46+ public static <T > Matcher <T []> hasItemInArray (T element ) {
47+ return IsArrayContaining .hasItemInArray (element );
4248 }
4349
4450 /**
@@ -51,8 +57,8 @@ public static <T> org.hamcrest.Matcher<T[]> hasItemInArray(T element) {
5157 * @param items the items that must equal the items within an examined array
5258 */
5359 @ SafeVarargs
54- public static <E > org . hamcrest . Matcher <E []> arrayContaining (E ... items ) {
55- return org . hamcrest . collection . IsArrayContainingInOrder .arrayContaining (items );
60+ public static <E > Matcher <E []> arrayContaining (E ... items ) {
61+ return IsArrayContainingInOrder .arrayContaining (items );
5662 }
5763
5864 /**
@@ -65,8 +71,8 @@ public static <E> org.hamcrest.Matcher<E[]> arrayContaining(E... items) {
6571 * @param itemMatchers the matchers that must be satisfied by the items in the examined array
6672 */
6773 @ SafeVarargs
68- public static <E > org . hamcrest . Matcher <E []> arrayContaining (org . hamcrest . Matcher <? super E >... itemMatchers ) {
69- return org . hamcrest . collection . IsArrayContainingInOrder .arrayContaining (itemMatchers );
74+ public static <E > Matcher <E []> arrayContaining (Matcher <? super E >... itemMatchers ) {
75+ return IsArrayContainingInOrder .arrayContaining (itemMatchers );
7076 }
7177
7278 /**
@@ -78,8 +84,8 @@ public static <E> org.hamcrest.Matcher<E[]> arrayContaining(org.hamcrest.Matcher
7884 *
7985 * @param itemMatchers a list of matchers, each of which must be satisfied by the corresponding item in an examined array
8086 */
81- public static <E > org . hamcrest . Matcher <E []> arrayContaining (java .util .List <org . hamcrest . Matcher <? super E >> itemMatchers ) {
82- return org . hamcrest . collection . IsArrayContainingInOrder .arrayContaining (itemMatchers );
87+ public static <E > Matcher <E []> arrayContaining (java .util .List <Matcher <? super E >> itemMatchers ) {
88+ return IsArrayContainingInOrder .arrayContaining (itemMatchers );
8389 }
8490
8591 /**
@@ -102,8 +108,8 @@ public static <E> org.hamcrest.Matcher<E[]> arrayContaining(java.util.List<org.h
102108 * @param itemMatchers a list of matchers, each of which must be satisfied by an entry in an examined array
103109 */
104110 @ SafeVarargs
105- public static <E > org . hamcrest . Matcher <E []> arrayContainingInAnyOrder (org . hamcrest . Matcher <? super E >... itemMatchers ) {
106- return org . hamcrest . collection . IsArrayContainingInAnyOrder .arrayContainingInAnyOrder (itemMatchers );
111+ public static <E > Matcher <E []> arrayContainingInAnyOrder (Matcher <? super E >... itemMatchers ) {
112+ return IsArrayContainingInAnyOrder .arrayContainingInAnyOrder (itemMatchers );
107113 }
108114
109115 /**
@@ -125,8 +131,8 @@ public static <E> org.hamcrest.Matcher<E[]> arrayContainingInAnyOrder(org.hamcre
125131 *
126132 * @param itemMatchers a list of matchers, each of which must be satisfied by an item provided by an examined array
127133 */
128- public static <E > org . hamcrest . Matcher <E []> arrayContainingInAnyOrder (java . util . Collection <org . hamcrest . Matcher <? super E >> itemMatchers ) {
129- return org . hamcrest . collection . IsArrayContainingInAnyOrder .arrayContainingInAnyOrder (itemMatchers );
134+ public static <E > Matcher <E []> arrayContainingInAnyOrder (Collection <Matcher <? super E >> itemMatchers ) {
135+ return IsArrayContainingInAnyOrder .arrayContainingInAnyOrder (itemMatchers );
130136 }
131137
132138 /**
@@ -147,8 +153,8 @@ public static <E> org.hamcrest.Matcher<E[]> arrayContainingInAnyOrder(java.util.
147153 * @param items the items that must equal the entries of an examined array, in any order
148154 */
149155 @ SafeVarargs
150- public static <E > org . hamcrest . Matcher <E []> arrayContainingInAnyOrder (E ... items ) {
151- return org . hamcrest . collection . IsArrayContainingInAnyOrder .arrayContainingInAnyOrder (items );
156+ public static <E > Matcher <E []> arrayContainingInAnyOrder (E ... items ) {
157+ return IsArrayContainingInAnyOrder .arrayContainingInAnyOrder (items );
152158 }
153159
154160 /**
@@ -159,8 +165,8 @@ public static <E> org.hamcrest.Matcher<E[]> arrayContainingInAnyOrder(E... items
159165 *
160166 * @param sizeMatcher a matcher for the length of an examined array
161167 */
162- public static <E > org . hamcrest . Matcher <E []> arrayWithSize (org . hamcrest . Matcher <? super java . lang . Integer > sizeMatcher ) {
163- return org . hamcrest . collection . IsArrayWithSize .arrayWithSize (sizeMatcher );
168+ public static <E > Matcher <E []> arrayWithSize (Matcher <? super Integer > sizeMatcher ) {
169+ return IsArrayWithSize .arrayWithSize (sizeMatcher );
164170 }
165171
166172 /**
@@ -171,8 +177,8 @@ public static <E> org.hamcrest.Matcher<E[]> arrayWithSize(org.hamcrest.Matcher<?
171177 *
172178 * @param size the length that an examined array must have for a positive match
173179 */
174- public static <E > org . hamcrest . Matcher <E []> arrayWithSize (int size ) {
175- return org . hamcrest . collection . IsArrayWithSize .arrayWithSize (size );
180+ public static <E > Matcher <E []> arrayWithSize (int size ) {
181+ return IsArrayWithSize .arrayWithSize (size );
176182 }
177183
178184 /**
@@ -181,8 +187,8 @@ public static <E> org.hamcrest.Matcher<E[]> arrayWithSize(int size) {
181187 * For example:
182188 * <pre>assertThat(new String[0], emptyArray())</pre>
183189 */
184- public static <E > org . hamcrest . Matcher <E []> emptyArray () {
185- return org . hamcrest . collection . IsArrayWithSize .emptyArray ( );
190+ public static <E > Matcher <E []> emptyArray () {
191+ return describedAs ( "an empty array" , IsArrayWithSize .< E > arrayWithSize ( 0 ) );
186192 }
187193
188194}
0 commit comments