|
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 |
| -import java.util.ArrayList; |
9 | 7 | import java.util.List;
|
10 | 8 |
|
11 |
| -import static java.util.Arrays.asList; |
12 |
| -import static org.hamcrest.core.IsEqual.equalTo; |
13 |
| - |
14 | 9 | public class IsIterableContainingInOrder<E> extends TypeSafeDiagnosingMatcher<Iterable<? extends E>> {
|
15 | 10 | private final List<Matcher<? super E>> matchers;
|
16 | 11 |
|
@@ -80,76 +75,4 @@ private void describeMismatch(Matcher<? super F> matcher, F item) {
|
80 | 75 | matcher.describeMismatch(item, mismatchDescription);
|
81 | 76 | }
|
82 | 77 | }
|
83 |
| - |
84 |
| - /** |
85 |
| - * Creates a matcher for {@link Iterable}s that matches when a single pass over the |
86 |
| - * examined {@link Iterable} yields a series of items, each logically equal to the |
87 |
| - * corresponding item in the specified items. For a positive match, the examined iterable |
88 |
| - * must be of the same length as the number of specified items. |
89 |
| - * For example: |
90 |
| - * <pre>assertThat(Arrays.asList("foo", "bar"), contains("foo", "bar"))</pre> |
91 |
| - * |
92 |
| - * @param items |
93 |
| - * the items that must equal the items provided by an examined {@link Iterable} |
94 |
| - */ |
95 |
| - @SafeVarargs |
96 |
| - public static <E> Matcher<Iterable<? extends E>> contains(E... items) { |
97 |
| - List<Matcher<? super E>> matchers = new ArrayList<>(); |
98 |
| - for (E item : items) { |
99 |
| - matchers.add(equalTo(item)); |
100 |
| - } |
101 |
| - |
102 |
| - return contains(matchers); |
103 |
| - } |
104 |
| - |
105 |
| - /** |
106 |
| - * Creates a matcher for {@link Iterable}s that matches when a single pass over the |
107 |
| - * examined {@link Iterable} yields a single item that satisfies the specified matcher. |
108 |
| - * For a positive match, the examined iterable must only yield one item. |
109 |
| - * For example: |
110 |
| - * <pre>assertThat(Arrays.asList("foo"), contains(equalTo("foo")))</pre> |
111 |
| - * |
112 |
| - * @param itemMatcher |
113 |
| - * the matcher that must be satisfied by the single item provided by an |
114 |
| - * examined {@link Iterable} |
115 |
| - */ |
116 |
| - @SuppressWarnings("unchecked") |
117 |
| - public static <E> Matcher<Iterable<? extends E>> contains(final Matcher<? super E> itemMatcher) { |
118 |
| - return contains(new ArrayList<Matcher<? super E>>(asList(itemMatcher))); |
119 |
| - } |
120 |
| - |
121 |
| - /** |
122 |
| - * Creates a matcher for {@link Iterable}s that matches when a single pass over the |
123 |
| - * examined {@link Iterable} yields a series of items, each satisfying the corresponding |
124 |
| - * matcher in the specified matchers. For a positive match, the examined iterable |
125 |
| - * must be of the same length as the number of specified matchers. |
126 |
| - * For example: |
127 |
| - * <pre>assertThat(Arrays.asList("foo", "bar"), contains(equalTo("foo"), equalTo("bar")))</pre> |
128 |
| - * |
129 |
| - * @param itemMatchers |
130 |
| - * the matchers that must be satisfied by the items provided by an examined {@link Iterable} |
131 |
| - */ |
132 |
| - @SafeVarargs |
133 |
| - public static <E> Matcher<Iterable<? extends E>> contains(Matcher<? super E>... itemMatchers) { |
134 |
| - // required for JDK 1.6 |
135 |
| - //noinspection RedundantTypeArguments |
136 |
| - final List<Matcher<? super E>> nullSafeWithExplicitTypeMatchers = Wrapping.<E>nullSafe(itemMatchers); |
137 |
| - return contains(nullSafeWithExplicitTypeMatchers); |
138 |
| - } |
139 |
| - |
140 |
| - /** |
141 |
| - * Creates a matcher for {@link Iterable}s that matches when a single pass over the |
142 |
| - * examined {@link Iterable} yields a series of items, each satisfying the corresponding |
143 |
| - * matcher in the specified list of matchers. For a positive match, the examined iterable |
144 |
| - * must be of the same length as the specified list of matchers. |
145 |
| - * For example: |
146 |
| - * <pre>assertThat(Arrays.asList("foo", "bar"), contains(Arrays.asList(equalTo("foo"), equalTo("bar"))))</pre> |
147 |
| - * |
148 |
| - * @param itemMatchers |
149 |
| - * a list of matchers, each of which must be satisfied by the corresponding item provided by |
150 |
| - * an examined {@link Iterable} |
151 |
| - */ |
152 |
| - public static <E> Matcher<Iterable<? extends E>> contains(List<Matcher<? super E>> itemMatchers) { |
153 |
| - return new IsIterableContainingInOrder<>(itemMatchers); |
154 |
| - } |
155 | 78 | }
|
0 commit comments