com.vtence.molecule.lib.matchers.AnyOf 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.lib.matchers;
import java.util.Arrays;
public class AnyOf implements Matcher {
private final Iterable> matchers;
public AnyOf(Iterable> matchers) {
this.matchers = matchers;
}
public boolean matches(T actual) {
for (Matcher super T> matcher : matchers) {
if (matcher.matches(actual)) return true;
}
return false;
}
@SuppressWarnings("unchecked")
public static Matcher anyOf(Matcher super T>... matchers) {
return new AnyOf<>(Arrays.asList(matchers));
}
@SuppressWarnings("unchecked")
public static Matcher anyOf(Iterable> matchers) {
return new AnyOf<>(matchers);
}
}