Skip to content

Commit 3ff8c34

Browse files
committed
Collapsing factory methods. remove IsArrayWithSize
1 parent b99812c commit 3ff8c34

File tree

3 files changed

+8
-51
lines changed

3 files changed

+8
-51
lines changed

hamcrest-library/src/main/java/org/hamcrest/Matchers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ public static <E> org.hamcrest.Matcher<E[]> arrayContainingInAnyOrder(E... items
634634
* @param sizeMatcher a matcher for the length of an examined array
635635
*/
636636
public static <E> org.hamcrest.Matcher<E[]> arrayWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher) {
637-
return org.hamcrest.collection.IsArrayWithSize.arrayWithSize(sizeMatcher);
637+
return MatchArrays.arrayWithSize(sizeMatcher);
638638
}
639639

640640
/**

hamcrest-library/src/main/java/org/hamcrest/collection/IsArrayWithSize.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

hamcrest-library/src/main/java/org/hamcrest/collection/MatchArrays.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package org.hamcrest.collection;
22

3+
import org.hamcrest.FeatureMatcher;
34
import org.hamcrest.Matcher;
45

56
import java.util.Collection;
67

78
import static org.hamcrest.core.DescribedAs.describedAs;
9+
import static org.hamcrest.core.IsEqual.equalTo;
810

911
public class MatchArrays {
1012
/**
@@ -166,7 +168,9 @@ public static <E> Matcher<E[]> arrayContainingInAnyOrder(E... items) {
166168
* @param sizeMatcher a matcher for the length of an examined array
167169
*/
168170
public static <E> Matcher<E[]> arrayWithSize(Matcher<? super Integer> sizeMatcher) {
169-
return IsArrayWithSize.arrayWithSize(sizeMatcher);
171+
return new FeatureMatcher<E[], Integer> (sizeMatcher, "an array with size","array size") {
172+
@Override protected Integer featureValueOf(E[] actual) { return actual.length; }
173+
};
170174
}
171175

172176
/**
@@ -178,7 +182,7 @@ public static <E> Matcher<E[]> arrayWithSize(Matcher<? super Integer> sizeMatche
178182
* @param size the length that an examined array must have for a positive match
179183
*/
180184
public static <E> Matcher<E[]> arrayWithSize(int size) {
181-
return IsArrayWithSize.arrayWithSize(size);
185+
return arrayWithSize(equalTo(size));
182186
}
183187

184188
/**
@@ -188,7 +192,7 @@ public static <E> Matcher<E[]> arrayWithSize(int size) {
188192
* <pre>assertThat(new String[0], emptyArray())</pre>
189193
*/
190194
public static <E> Matcher<E[]> emptyArray() {
191-
return describedAs("an empty array", IsArrayWithSize.<E>arrayWithSize(0));
195+
return describedAs("an empty array", MatchArrays.<E>arrayWithSize(0));
192196
}
193197

194198
}

0 commit comments

Comments
 (0)