io.github.olib963.javatest.matchers.internal.ElementThatMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javatest-matchers Show documentation
Show all versions of javatest-matchers Show documentation
Matchers to create assertions from common conditions
package io.github.olib963.javatest.matchers.internal;
import io.github.olib963.javatest.matchers.MatchResult;
import io.github.olib963.javatest.matchers.Matcher;
import java.util.Collection;
public class ElementThatMatcher implements Matcher> {
private final Matcher elementMatcher;
public ElementThatMatcher(Matcher elementMatcher) {
this.elementMatcher = elementMatcher;
}
@Override
public MatchResult matches(Collection value) {
return MatchResult.of(
value.stream()
.map(elementMatcher::matches)
.anyMatch(r -> r.matches));
}
@Override
public String describeExpected() {
return "contain an element that was expected to " + elementMatcher.describeExpected();
}
}