org.jboss.weld.metadata.ScanningPredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weld-osgi-bundle Show documentation
Show all versions of weld-osgi-bundle Show documentation
Weld runtime packaged as an OSGi bundle
package org.jboss.weld.metadata;
import com.google.common.base.Predicate;
import java.util.Collection;
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 apply(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.apply(input)) {
apply = true;
}
}
for (Predicate exclude : excludes) {
// If any exclude matches, we exclude the class - we can then short-circuit
if (exclude.apply(input)) {
return false;
}
}
return apply;
}
}