|
3 | 3 | import org.hamcrest.Description;
|
4 | 4 | import org.hamcrest.Matcher;
|
5 | 5 | import org.hamcrest.TypeSafeDiagnosingMatcher;
|
6 |
| -import org.hamcrest.internal.Wrapping; |
7 | 6 |
|
8 | 7 | import java.util.ArrayList;
|
9 | 8 | import java.util.Collection;
|
10 | 9 |
|
11 |
| -import static java.util.Arrays.asList; |
12 |
| - |
13 | 10 | public class IsIterableContainingInAnyOrder<T> extends TypeSafeDiagnosingMatcher<Iterable<? extends T>> {
|
14 | 11 | private final Collection<Matcher<? super T>> matchers;
|
15 | 12 |
|
@@ -74,77 +71,5 @@ private boolean isMatched(S item) {
|
74 | 71 | return false;
|
75 | 72 | }
|
76 | 73 | }
|
77 |
| - |
78 |
| - /** |
79 |
| - * <p> |
80 |
| - * Creates an order agnostic matcher for {@link Iterable}s that matches when a single pass over |
81 |
| - * the examined {@link Iterable} yields a series of items, each satisfying one matcher anywhere |
82 |
| - * in the specified matchers. For a positive match, the examined iterable must be of the same |
83 |
| - * length as the number of specified matchers. |
84 |
| - * </p> |
85 |
| - * <p> |
86 |
| - * N.B. each of the specified matchers will only be used once during a given examination, so be |
87 |
| - * careful when specifying matchers that may be satisfied by more than one entry in an examined |
88 |
| - * iterable. |
89 |
| - * </p> |
90 |
| - * <p> |
91 |
| - * For example: |
92 |
| - * </p> |
93 |
| - * <pre>assertThat(Arrays.asList("foo", "bar"), containsInAnyOrder(equalTo("bar"), equalTo("foo")))</pre> |
94 |
| - * |
95 |
| - * @param itemMatchers |
96 |
| - * a list of matchers, each of which must be satisfied by an item provided by an examined {@link Iterable} |
97 |
| - */ |
98 |
| - @SafeVarargs |
99 |
| - public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(Matcher<? super T>... itemMatchers) { |
100 |
| - return containsInAnyOrder(asList(itemMatchers)); |
101 |
| - } |
102 |
| - |
103 |
| - /** |
104 |
| - * <p> |
105 |
| - * Creates an order agnostic matcher for {@link Iterable}s that matches when a single pass over |
106 |
| - * the examined {@link Iterable} yields a series of items, each logically equal to one item |
107 |
| - * anywhere in the specified items. For a positive match, the examined iterable |
108 |
| - * must be of the same length as the number of specified items. |
109 |
| - * </p> |
110 |
| - * <p> |
111 |
| - * N.B. each of the specified items will only be used once during a given examination, so be |
112 |
| - * careful when specifying items that may be equal to more than one entry in an examined |
113 |
| - * iterable. |
114 |
| - * </p> |
115 |
| - * <p> |
116 |
| - * For example: |
117 |
| - * </p> |
118 |
| - * <pre>assertThat(Arrays.asList("foo", "bar"), containsInAnyOrder("bar", "foo"))</pre> |
119 |
| - * |
120 |
| - * @param items |
121 |
| - * the items that must equal the items provided by an examined {@link Iterable} in any order |
122 |
| - */ |
123 |
| - @SafeVarargs |
124 |
| - public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(T... items) { |
125 |
| - return new IsIterableContainingInAnyOrder<>(Wrapping.asEqualToMatchers(items)); |
126 |
| - } |
127 |
| - |
128 |
| - /** |
129 |
| - * <p> |
130 |
| - * Creates an order agnostic matcher for {@link Iterable}s that matches when a single pass over |
131 |
| - * the examined {@link Iterable} yields a series of items, each satisfying one matcher anywhere |
132 |
| - * in the specified collection of matchers. For a positive match, the examined iterable |
133 |
| - * must be of the same length as the specified collection of matchers. |
134 |
| - * </p> |
135 |
| - * <p> |
136 |
| - * N.B. each matcher in the specified collection will only be used once during a given |
137 |
| - * examination, so be careful when specifying matchers that may be satisfied by more than |
138 |
| - * one entry in an examined iterable. |
139 |
| - * </p> |
140 |
| - * <p>For example:</p> |
141 |
| - * <pre>assertThat(Arrays.asList("foo", "bar"), containsInAnyOrder(Arrays.asList(equalTo("bar"), equalTo("foo"))))</pre> |
142 |
| - * |
143 |
| - * @param itemMatchers |
144 |
| - * a list of matchers, each of which must be satisfied by an item provided by an examined {@link Iterable} |
145 |
| - */ |
146 |
| - public static <T> Matcher<Iterable<? extends T>> containsInAnyOrder(Collection<Matcher<? super T>> itemMatchers) { |
147 |
| - return new IsIterableContainingInAnyOrder<>(itemMatchers); |
148 |
| - } |
149 | 74 | }
|
150 | 75 |
|
0 commit comments