> matchers) {
this.matchers = matchers;
}
@Override
public boolean matches(Object o, Description mismatch) {
for (Matcher super T> matcher : matchers) {
if (!matcher.matches(o)) {
mismatch.appendDescriptionOf(matcher).appendText(" ");
matcher.describeMismatch(o, mismatch);
return false;
}
}
return true;
}
@Override
public void describeTo(Description description) {
description.appendList("(", " " + "and" + " ", ")", matchers);
}
/**
* Creates a matcher that matches if the examined object matches ALL of the specified matchers.
* For example:
* assertThat("myValue", allOf(startsWith("my"), containsString("Val")))
*/
public static Matcher allOf(Iterable> matchers) {
return new AllOf<>(matchers);
}
/**
* Creates a matcher that matches if the examined object matches ALL of the specified matchers.
* For example:
* assertThat("myValue", allOf(startsWith("my"), containsString("Val")))
*/
@SafeVarargs
public static Matcher allOf(Matcher super T>... matchers) {
return allOf((List) Arrays.asList(matchers));
}
}