@Override protected boolean matchesSafely(Iterable<? super T> collection, Description mismatchDescription) { if (isEmpty(collection)) { mismatchDescription.appendText("was empty"); return false; } for (Object item : collection) { if (elementMatcher.matches(item)) { return true; } } mismatchDescription.appendText("mismatches were: ["); boolean isPastFirst = false; for (Object item : collection) { if (isPastFirst) { mismatchDescription.appendText(", "); } elementMatcher.describeMismatch(item, mismatchDescription); isPastFirst = true; } mismatchDescription.appendText("]"); return false; }
@Override protected boolean matchesSafely(Iterable<? super T> collection, Description mismatchDescription) { if (isEmpty(collection)) { mismatchDescription.appendText("was empty"); return false; } for (Object item : collection) { if (elementMatcher.matches(item)) { return true; } } mismatchDescription.appendText("mismatches were: ["); boolean isPastFirst = false; for (Object item : collection) { if (isPastFirst) { mismatchDescription.appendText(", "); } elementMatcher.describeMismatch(item, mismatchDescription); isPastFirst = true; } mismatchDescription.appendText("]"); return false; }