Skip to content

Commit 88c6c7b

Browse files
committed
Factory methods. Iterables contains in relative order
1 parent ee836b8 commit 88c6c7b

File tree

3 files changed

+4
-58
lines changed

3 files changed

+4
-58
lines changed

hamcrest-library/src/main/java/org/hamcrest/Matchers.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ public static <T> org.hamcrest.Matcher<java.lang.Iterable<? extends T>> contains
900900
*/
901901
@SafeVarargs
902902
public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> containsInRelativeOrder(E... items) {
903-
return org.hamcrest.collection.IsIterableContainingInRelativeOrder.containsInRelativeOrder(items);
903+
return MatchIterables.containsInRelativeOrder(items);
904904
}
905905

906906
/**
@@ -914,7 +914,7 @@ public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> contains
914914
*/
915915
@SafeVarargs
916916
public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> containsInRelativeOrder(Matcher<? super E>... itemMatchers) {
917-
return org.hamcrest.collection.IsIterableContainingInRelativeOrder.containsInRelativeOrder(itemMatchers);
917+
return MatchIterables.containsInRelativeOrder(itemMatchers);
918918
}
919919

920920
/**
@@ -928,7 +928,7 @@ public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> contains
928928
* an examined {@link Iterable} in the same relative order
929929
*/
930930
public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> containsInRelativeOrder(java.util.List<Matcher<? super E>> itemMatchers) {
931-
return org.hamcrest.collection.IsIterableContainingInRelativeOrder.containsInRelativeOrder(itemMatchers);
931+
return MatchIterables.containsInRelativeOrder(itemMatchers);
932932
}
933933

934934
/**

hamcrest-library/src/main/java/org/hamcrest/collection/IsIterableContainingInRelativeOrder.java

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
import org.hamcrest.Matcher;
55
import org.hamcrest.TypeSafeDiagnosingMatcher;
66

7-
import java.util.ArrayList;
87
import java.util.List;
98

10-
import static java.util.Arrays.asList;
11-
import static org.hamcrest.core.IsEqual.equalTo;
12-
139
public class IsIterableContainingInRelativeOrder<E> extends TypeSafeDiagnosingMatcher<Iterable<? extends E>> {
1410
private final List<Matcher<? super E>> matchers;
1511

@@ -65,54 +61,4 @@ public boolean isFinished() {
6561
}
6662

6763
}
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-
}
11864
}

hamcrest-library/src/test/java/org/hamcrest/collection/IsIterableContainingInRelativeOrderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.List;
99

1010
import static java.util.Arrays.asList;
11-
import static org.hamcrest.collection.IsIterableContainingInRelativeOrder.containsInRelativeOrder;
11+
import static org.hamcrest.collection.MatchIterables.containsInRelativeOrder;
1212
import static org.hamcrest.core.IsEqual.equalTo;
1313

1414
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)