Skip to content

Commit 7318fc9

Browse files
committed
Factory methods. Any IsAnything
1 parent c39a881 commit 7318fc9

7 files changed

Lines changed: 17 additions & 26 deletions

File tree

‎hamcrest-core/src/main/java/org/hamcrest/CoreMatchers.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.hamcrest;
22

3+
import org.hamcrest.collection.MatchingIterables;
4+
import org.hamcrest.object.MatchingObjects;
5+
36
@SuppressWarnings("UnusedDeclaration")
47
public class CoreMatchers {
58

@@ -88,7 +91,7 @@ public static <T> org.hamcrest.Matcher<T> describedAs(java.lang.String descripti
8891
* the matcher to apply to every item provided by the examined {@link Iterable}
8992
*/
9093
public static <U> org.hamcrest.Matcher<java.lang.Iterable<? extends U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) {
91-
return org.hamcrest.core.Every.everyItem(itemMatcher);
94+
return MatchingIterables.everyItem(itemMatcher);
9295
}
9396

9497
/**
@@ -129,7 +132,7 @@ public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type) {
129132
* Creates a matcher that always matches, regardless of the examined object.
130133
*/
131134
public static org.hamcrest.Matcher<java.lang.Object> anything() {
132-
return org.hamcrest.core.IsAnything.anything();
135+
return MatchingObjects.anything();
133136
}
134137

135138
/**
@@ -140,7 +143,7 @@ public static org.hamcrest.Matcher<java.lang.Object> anything() {
140143
* a meaningful {@link String} used when describing itself
141144
*/
142145
public static org.hamcrest.Matcher<java.lang.Object> anything(java.lang.String description) {
143-
return org.hamcrest.core.IsAnything.anything(description);
146+
return MatchingObjects.anything(description);
144147
}
145148

146149
/**

‎hamcrest-core/src/main/java/org/hamcrest/core/Every.java‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,4 @@ public boolean matchesSafely(Iterable<? extends T> collection, Description misma
2727
public void describeTo(Description description) {
2828
description.appendText("every item is ").appendDescriptionOf(matcher);
2929
}
30-
31-
/**
32-
* Creates a matcher for {@link Iterable}s that only matches when a single pass over the
33-
* examined {@link Iterable} yields items that are all matched by the specified
34-
* <code>itemMatcher</code>.
35-
* For example:
36-
* <pre>assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba")))</pre>
37-
*
38-
* @param itemMatcher
39-
* the matcher to apply to every item provided by the examined {@link Iterable}
40-
*/
41-
public static <U> Matcher<Iterable<? extends U>> everyItem(final Matcher<U> itemMatcher) {
42-
return new Every<>(itemMatcher);
43-
}
4430
}

‎hamcrest-core/src/test/java/org/hamcrest/core/DescribedAsTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import static org.hamcrest.AbstractMatcherTest.*;
99
import static org.hamcrest.core.DescribedAs.describedAs;
10-
import static org.hamcrest.core.IsAnything.anything;
11-
import static org.hamcrest.core.IsEqual.equalTo;
10+
import static org.hamcrest.object.MatchingObjects.anything;
11+
import static org.hamcrest.object.MatchingObjects.equalTo;
1212

1313
public final class DescribedAsTest {
1414

‎hamcrest-core/src/test/java/org/hamcrest/core/EveryTest.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.hamcrest.core;
22

33
import org.hamcrest.Matcher;
4+
import org.hamcrest.collection.MatchingIterables;
45
import org.junit.Test;
56

67
import java.util.ArrayList;
@@ -11,7 +12,7 @@
1112

1213
public final class EveryTest {
1314

14-
private final Matcher<Iterable<? extends String>> matcher = Every.everyItem(containsString("a"));
15+
private final Matcher<Iterable<? extends String>> matcher = MatchingIterables.everyItem(containsString("a"));
1516

1617
@Test public void
1718
copesWithNullsAndUnknownTypes() {

‎hamcrest-core/src/test/java/org/hamcrest/core/IsAnythingTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import static org.hamcrest.AbstractMatcherTest.assertDescription;
99
import static org.hamcrest.AbstractMatcherTest.assertMatches;
10-
import static org.hamcrest.core.IsAnything.anything;
10+
import static org.hamcrest.object.MatchingObjects.anything;
1111

1212
public final class IsAnythingTest {
1313

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static <T> Matcher<T> describedAs(java.lang.String description, Matcher<T
139139
* @param itemMatcher the matcher to apply to every item provided by the examined {@link Iterable}
140140
*/
141141
public static <U> org.hamcrest.Matcher<java.lang.Iterable<? extends U>> everyItem(org.hamcrest.Matcher<U> itemMatcher) {
142-
return org.hamcrest.core.Every.everyItem(itemMatcher);
142+
return MatchingIterables.everyItem(itemMatcher);
143143
}
144144

145145
/**
@@ -180,7 +180,7 @@ public static <T> Matcher<T> isA(Class<T> type) {
180180
* Creates a matcher that always matches, regardless of the examined object.
181181
*/
182182
public static org.hamcrest.Matcher<Object> anything() {
183-
return org.hamcrest.core.IsAnything.anything();
183+
return MatchingObjects.anything();
184184
}
185185

186186
/**
@@ -190,7 +190,7 @@ public static org.hamcrest.Matcher<Object> anything() {
190190
* @param description a meaningful {@link String} used when describing itself
191191
*/
192192
public static org.hamcrest.Matcher<Object> anything(java.lang.String description) {
193-
return org.hamcrest.core.IsAnything.anything(description);
193+
return MatchingObjects.anything(description);
194194
}
195195

196196
/**

‎hamcrest-library/src/main/java/org/hamcrest/collection/MatchingMaps.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
import java.util.Map;
66

7-
import static org.hamcrest.core.IsAnything.anything;
8-
import static org.hamcrest.core.IsEqual.equalTo;
7+
import static org.hamcrest.object.MatchingObjects.anything;
8+
import static org.hamcrest.object.MatchingObjects.equalTo;
9+
910

1011
public class MatchingMaps {
1112
/**

0 commit comments

Comments
 (0)