99import org .hamcrest .Matcher ;
1010
1111/**
12- * Calculates the logical disjunction of two matchers. Evaluation is
13- * shortcut, so that the second matcher is not called if the first
14- * matcher returns <code>true</code>.
12+ * Calculates the logical disjunction of multiple matchers. Evaluation is shortcut, so
13+ * subsequent matchers are not called if an earlier matcher returns <code>true</code>.
1514 */
1615public class AnyOf <T > extends ShortcutCombination <T > {
16+
1717 public AnyOf (Iterable <Matcher <? super T >> matchers ) {
1818 super (matchers );
1919 }
@@ -36,6 +36,14 @@ public static <T> Matcher<T> anyOf(Matcher<? super T>... matchers) {
3636 return anyOf (Arrays .asList (matchers ));
3737 }
3838
39+ /**
40+ * Evaluates to true if ANY of the passed in matchers evaluate to true.
41+ */
42+ @ Factory
43+ public static <T > Matcher <T > anyOf (Iterable <Matcher <? super T >> matchers ) {
44+ return new AnyOf <T >(matchers );
45+ }
46+
3947 /**
4048 * Evaluates to true if ANY of the passed in matchers evaluate to true.
4149 */
@@ -63,25 +71,25 @@ public static <T> Matcher<T> anyOf(Matcher<T> first, Matcher<? super T> second,
6371 * Evaluates to true if ANY of the passed in matchers evaluate to true.
6472 */
6573 @ Factory
66- public static <T > Matcher <T > anyOf (Matcher <T > first , Matcher <? super T > second , Matcher <? super T > third , Matcher <? super T > forth ) {
74+ public static <T > Matcher <T > anyOf (Matcher <T > first , Matcher <? super T > second , Matcher <? super T > third , Matcher <? super T > fourth ) {
6775 List <Matcher <? super T >> matchers = new ArrayList <Matcher <? super T >>();
6876 matchers .add (first );
6977 matchers .add (second );
7078 matchers .add (third );
71- matchers .add (forth );
79+ matchers .add (fourth );
7280 return anyOf (matchers );
7381 }
7482
7583 /**
7684 * Evaluates to true if ANY of the passed in matchers evaluate to true.
7785 */
7886 @ Factory
79- public static <T > Matcher <T > anyOf (Matcher <T > first , Matcher <? super T > second , Matcher <? super T > third , Matcher <? super T > forth , Matcher <? super T > fifth ) {
87+ public static <T > Matcher <T > anyOf (Matcher <T > first , Matcher <? super T > second , Matcher <? super T > third , Matcher <? super T > fourth , Matcher <? super T > fifth ) {
8088 List <Matcher <? super T >> matchers = new ArrayList <Matcher <? super T >>();
8189 matchers .add (first );
8290 matchers .add (second );
8391 matchers .add (third );
84- matchers .add (forth );
92+ matchers .add (fourth );
8593 matchers .add (fifth );
8694 return anyOf (matchers );
8795 }
@@ -90,22 +98,14 @@ public static <T> Matcher<T> anyOf(Matcher<T> first, Matcher<? super T> second,
9098 * Evaluates to true if ANY of the passed in matchers evaluate to true.
9199 */
92100 @ Factory
93- public static <T > Matcher <T > anyOf (Matcher <T > first , Matcher <? super T > second , Matcher <? super T > third , Matcher <? super T > forth , Matcher <? super T > fifth , Matcher <? super T > sixth ) {
101+ public static <T > Matcher <T > anyOf (Matcher <T > first , Matcher <? super T > second , Matcher <? super T > third , Matcher <? super T > fourth , Matcher <? super T > fifth , Matcher <? super T > sixth ) {
94102 List <Matcher <? super T >> matchers = new ArrayList <Matcher <? super T >>();
95103 matchers .add (first );
96104 matchers .add (second );
97105 matchers .add (third );
98- matchers .add (forth );
106+ matchers .add (fourth );
99107 matchers .add (fifth );
100108 matchers .add (sixth );
101109 return anyOf (matchers );
102110 }
103-
104- /**
105- * Evaluates to true if ANY of the passed in matchers evaluate to true.
106- */
107- @ Factory
108- public static <T > Matcher <T > anyOf (Iterable <Matcher <? super T >> matchers ) {
109- return new AnyOf <T >(matchers );
110- }
111111}
0 commit comments