11package org .hamcrest ;
22
3- import org .hamcrest .collection .HasSubsequence ;
4-
5- import java .util .ArrayList ;
6- import java .util .List ;
7-
8- import static java .util .Arrays .asList ;
3+ import org .hamcrest .text .MatchStrings ;
94
105@ SuppressWarnings ("UnusedDeclaration" )
116public class Matchers {
12-
137 /**
148 * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
159 * For example:
@@ -29,51 +23,6 @@ public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T>.
2923 return org .hamcrest .core .AllOf .allOf (matchers );
3024 }
3125
32- /**
33- * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
34- * For example:
35- * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
36- */
37- public static <T > org .hamcrest .Matcher <T > allOf (org .hamcrest .Matcher <? super T > first , org .hamcrest .Matcher <? super T > second ) {
38- return org .hamcrest .core .AllOf .allOf (first , second );
39- }
40-
41- /**
42- * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
43- * For example:
44- * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
45- */
46- public static <T > org .hamcrest .Matcher <T > allOf (org .hamcrest .Matcher <? super T > first , org .hamcrest .Matcher <? super T > second , org .hamcrest .Matcher <? super T > third ) {
47- return org .hamcrest .core .AllOf .allOf (first , second , third );
48- }
49-
50- /**
51- * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
52- * For example:
53- * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
54- */
55- public static <T > org .hamcrest .Matcher <T > allOf (org .hamcrest .Matcher <? super T > first , org .hamcrest .Matcher <? super T > second , org .hamcrest .Matcher <? super T > third , org .hamcrest .Matcher <? super T > fourth ) {
56- return org .hamcrest .core .AllOf .allOf (first , second , third , fourth );
57- }
58-
59- /**
60- * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
61- * For example:
62- * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
63- */
64- public static <T > org .hamcrest .Matcher <T > allOf (org .hamcrest .Matcher <? super T > first , org .hamcrest .Matcher <? super T > second , org .hamcrest .Matcher <? super T > third , org .hamcrest .Matcher <? super T > fourth , org .hamcrest .Matcher <? super T > fifth ) {
65- return org .hamcrest .core .AllOf .allOf (first , second , third , fourth , fifth );
66- }
67-
68- /**
69- * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
70- * For example:
71- * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre>
72- */
73- public static <T > org .hamcrest .Matcher <T > allOf (org .hamcrest .Matcher <? super T > first , org .hamcrest .Matcher <? super T > second , org .hamcrest .Matcher <? super T > third , org .hamcrest .Matcher <? super T > fourth , org .hamcrest .Matcher <? super T > fifth , org .hamcrest .Matcher <? super T > sixth ) {
74- return org .hamcrest .core .AllOf .allOf (first , second , third , fourth , fifth , sixth );
75- }
76-
7726 /**
7827 * Creates a matcher that matches if the examined object matches <b>ANY</b> of the specified matchers.
7928 * For example:
@@ -1359,15 +1308,15 @@ public static org.hamcrest.Matcher<java.lang.String> blankString() {
13591308 * exactly matches the given {@link java.util.regex.Pattern}.
13601309 */
13611310 public static org .hamcrest .Matcher <java .lang .String > matchesPattern (java .util .regex .Pattern pattern ) {
1362- return org . hamcrest . text . MatchesPattern .matchesPattern (pattern );
1311+ return MatchStrings .matchesPattern (pattern );
13631312 }
13641313
13651314 /**
13661315 * Creates a matcher of {@link java.lang.String} that matches when the examined string
13671316 * exactly matches the given regular expression, treated as a {@link java.util.regex.Pattern}.
13681317 */
13691318 public static org .hamcrest .Matcher <java .lang .String > matchesPattern (java .lang .String regex ) {
1370- return org . hamcrest . text . MatchesPattern .matchesPattern (regex );
1319+ return MatchStrings .matchesPattern (regex );
13711320 }
13721321
13731322 /**
@@ -1548,25 +1497,4 @@ public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String x
15481497 return org .hamcrest .xml .HasXPath .hasXPath (xPath , namespaceContext );
15491498 }
15501499
1551- public static <T > Matcher <Iterable <? extends T >> hasSubsequence (List <Matcher <? super T >> matchers ) {
1552- return new HasSubsequence <>(matchers );
1553- }
1554-
1555- @ SafeVarargs
1556- public static <T > Matcher <Iterable <? extends T >> hasSubsequence (Matcher <? super T >... matchers ) {
1557- return hasSubsequence (asList (matchers ));
1558- }
1559-
1560- public static <T > Matcher <Iterable <? extends T >> hasSubsequence (Iterable <? extends T > items ) {
1561- List <Matcher <? super T >> matchers = new ArrayList <>();
1562- for (Object item : items ) {
1563- matchers .add (equalTo (item ));
1564- }
1565- return new HasSubsequence <>(matchers );
1566- }
1567-
1568- @ SafeVarargs
1569- public static <T > Matcher <Iterable <? extends T >> hasSubsequence (T ... elements ) {
1570- return hasSubsequence (asList (elements ));
1571- }
15721500}
0 commit comments