|
3 | 3 | import org.hamcrest.BaseMatcher; |
4 | 4 | import org.hamcrest.Description; |
5 | 5 | import org.hamcrest.Matcher; |
6 | | -import org.hamcrest.introspection.Combination; |
7 | 6 |
|
8 | | -abstract class ShortcutCombination<T> extends BaseMatcher<T> implements Combination { |
| 7 | +abstract class ShortcutCombination<T> extends BaseMatcher<T> { |
9 | 8 | private final Iterable<Matcher<? super T>> matchers; |
10 | 9 |
|
11 | 10 | public ShortcutCombination(Iterable<Matcher<? super T>> matchers) { |
12 | 11 | this.matchers = matchers; |
13 | 12 | } |
14 | | - |
15 | | - public boolean matches(Object o) { |
| 13 | + |
| 14 | + public abstract boolean matches(Object o); |
| 15 | + |
| 16 | + public abstract void describeTo(Description description); |
| 17 | + |
| 18 | + |
| 19 | + protected boolean matches(Object o, boolean shortcut) { |
16 | 20 | for (Matcher<? super T> matcher : matchers) { |
17 | | - if (matcher.matches(o) == shortcut()) { |
18 | | - return shortcut(); |
| 21 | + if (matcher.matches(o) == shortcut) { |
| 22 | + return shortcut; |
19 | 23 | } |
20 | 24 | } |
21 | | - return !shortcut(); |
22 | | - } |
23 | | - |
24 | | - protected abstract boolean shortcut(); |
25 | | - |
26 | | - public void describeTo(Description description) { |
27 | | - description.appendList("(", " and ", ")", matchers); |
| 25 | + return !shortcut; |
28 | 26 | } |
29 | 27 |
|
30 | | - public Iterable<? extends Matcher<? super T>> combined() { |
31 | | - return matchers; |
| 28 | + public void describeTo(Description description, String operator) { |
| 29 | + description.appendList("(", " " + operator + " ", ")", matchers); |
32 | 30 | } |
33 | 31 | } |
0 commit comments