All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.olib963.javatest.matchers.internal.ElementThatMatcher Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy