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