com.vtence.molecule.matchers.AllOf Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of molecule Show documentation
Show all versions of molecule Show documentation
A web micro-framework for Java
package com.vtence.molecule.matchers;
import com.vtence.molecule.Matcher;
import java.util.Arrays;
public class AllOf implements Matcher {
private final Iterable> matchers;
public AllOf(Iterable> matchers) {
this.matchers = matchers;
}
public boolean matches(T actual) {
for (Matcher super T> matcher : matchers) {
if (!matcher.matches(actual)) return false;
}
return true;
}
@SuppressWarnings("unchecked")
public static Matcher allOf(Matcher super T>... matchers) {
return new AllOf(Arrays.asList(matchers));
}
}