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

org.jboss.weld.metadata.ScanningPredicate Maven / Gradle / Ivy

Go to download

This jar bundles all the bits of Weld and CDI required for running in a Servlet container.

There is a newer version: 6.0.0.Beta4
Show newest version
package org.jboss.weld.metadata;

import java.util.Collection;
import java.util.function.Predicate;

public class ScanningPredicate implements Predicate {

    private final Collection> includes;
    private final Collection> excludes;

    public ScanningPredicate(Collection> includes, Collection> excludes) {
        this.includes = includes;
        this.excludes = excludes;
    }

    public boolean test(T input) {
        // Initial state - all classes are included if no includes are specified
        boolean apply = includes.isEmpty();

        for (Predicate include : includes) {
            // If any include matches, we should include the class
            if (include.test(input)) {
                apply = true;
            }
        }
        for (Predicate exclude : excludes) {
            // If any exclude matches, we exclude the class - we can then short-circuit
            if (exclude.test(input)) {
                return false;
            }
        }
        return apply;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy