1
1
package org .hamcrest ;
2
2
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 ;
9
4
10
5
@ SuppressWarnings ("UnusedDeclaration" )
11
6
public class Matchers {
12
-
13
7
/**
14
8
* Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers.
15
9
* For example:
@@ -29,51 +23,6 @@ public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T>.
29
23
return org .hamcrest .core .AllOf .allOf (matchers );
30
24
}
31
25
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
-
77
26
/**
78
27
* Creates a matcher that matches if the examined object matches <b>ANY</b> of the specified matchers.
79
28
* For example:
@@ -1359,15 +1308,15 @@ public static org.hamcrest.Matcher<java.lang.String> blankString() {
1359
1308
* exactly matches the given {@link java.util.regex.Pattern}.
1360
1309
*/
1361
1310
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 );
1363
1312
}
1364
1313
1365
1314
/**
1366
1315
* Creates a matcher of {@link java.lang.String} that matches when the examined string
1367
1316
* exactly matches the given regular expression, treated as a {@link java.util.regex.Pattern}.
1368
1317
*/
1369
1318
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 );
1371
1320
}
1372
1321
1373
1322
/**
@@ -1548,25 +1497,4 @@ public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String x
1548
1497
return org .hamcrest .xml .HasXPath .hasXPath (xPath , namespaceContext );
1549
1498
}
1550
1499
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
- }
1572
1500
}
0 commit comments