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

com.vtence.molecule.lib.matchers.AnyOf Maven / Gradle / Ivy

There is a newer version: 0.15.0
Show newest version
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 matcher : matchers) {
            if (matcher.matches(actual)) return true;
        }

        return false;
    }

    @SuppressWarnings("unchecked")
    public static  Matcher anyOf(Matcher... matchers) {
        return new AnyOf<>(Arrays.asList(matchers));
    }

    @SuppressWarnings("unchecked")
    public static  Matcher anyOf(Iterable> matchers) {
        return new AnyOf<>(matchers);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy