|
4 | 4 | import org.hamcrest.Matcher; |
5 | 5 | import org.hamcrest.TypeSafeDiagnosingMatcher; |
6 | 6 |
|
7 | | -import java.util.ArrayList; |
8 | 7 | import java.util.List; |
9 | 8 |
|
10 | | -import static java.util.Arrays.asList; |
11 | | -import static org.hamcrest.core.IsEqual.equalTo; |
12 | | - |
13 | 9 | public class IsIterableContainingInRelativeOrder<E> extends TypeSafeDiagnosingMatcher<Iterable<? extends E>> { |
14 | 10 | private final List<Matcher<? super E>> matchers; |
15 | 11 |
|
@@ -65,54 +61,4 @@ public boolean isFinished() { |
65 | 61 | } |
66 | 62 |
|
67 | 63 | } |
68 | | - |
69 | | - /** |
70 | | - * Creates a matcher for {@link Iterable}s that matches when a single pass over the |
71 | | - * examined {@link Iterable} yields a series of items, that contains items logically equal to the |
72 | | - * corresponding item in the specified items, in the same relative order |
73 | | - * For example: |
74 | | - * <pre>assertThat(Arrays.asList("a", "b", "c", "d", "e"), containsInRelativeOrder("b", "d"))</pre> |
75 | | - * |
76 | | - * @param items |
77 | | - * the items that must be contained within items provided by an examined {@link Iterable} in the same relative order |
78 | | - */ |
79 | | - @SafeVarargs |
80 | | - public static <E> Matcher<Iterable<? extends E>> containsInRelativeOrder(E... items) { |
81 | | - List<Matcher<? super E>> matchers = new ArrayList<>(); |
82 | | - for (E item : items) { |
83 | | - matchers.add(equalTo(item)); |
84 | | - } |
85 | | - |
86 | | - return containsInRelativeOrder(matchers); |
87 | | - } |
88 | | - |
89 | | - /** |
90 | | - * Creates a matcher for {@link Iterable}s that matches when a single pass over the |
91 | | - * examined {@link Iterable} yields a series of items, that each satisfying the corresponding |
92 | | - * matcher in the specified matchers, in the same relative order. |
93 | | - * For example: |
94 | | - * <pre>assertThat(Arrays.asList("a", "b", "c", "d", "e"), containsInRelativeOrder(equalTo("b"), equalTo("d")))</pre> |
95 | | - * |
96 | | - * @param itemMatchers |
97 | | - * the matchers that must be satisfied by the items provided by an examined {@link Iterable} in the same relative order |
98 | | - */ |
99 | | - @SafeVarargs |
100 | | - public static <E> Matcher<Iterable<? extends E>> containsInRelativeOrder(Matcher<? super E>... itemMatchers) { |
101 | | - return containsInRelativeOrder(asList(itemMatchers)); |
102 | | - } |
103 | | - |
104 | | - /** |
105 | | - * Creates a matcher for {@link Iterable}s that matches when a single pass over the |
106 | | - * examined {@link Iterable} yields a series of items, that contains items satisfying the corresponding |
107 | | - * matcher in the specified list of matchers, in the same relative order. |
108 | | - * For example: |
109 | | - * <pre>assertThat(Arrays.asList("a", "b", "c", "d", "e"), contains(Arrays.asList(equalTo("b"), equalTo("d"))))</pre> |
110 | | - * |
111 | | - * @param itemMatchers |
112 | | - * a list of matchers, each of which must be satisfied by the items provided by |
113 | | - * an examined {@link Iterable} in the same relative order |
114 | | - */ |
115 | | - public static <E> Matcher<Iterable<? extends E>> containsInRelativeOrder(List<Matcher<? super E>> itemMatchers) { |
116 | | - return new IsIterableContainingInRelativeOrder<>(itemMatchers); |
117 | | - } |
118 | 64 | } |
0 commit comments