
aQute.lib.collections.Logic Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aQute.libg Show documentation
Show all versions of aQute.libg Show documentation
A library to be statically linked. Contains many small utilities. This bundle should not be installed in a framework, it is compile only.
package aQute.lib.collections;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class Logic {
// @SafeVarargs
public static Collection retain(Collection first, Collection... sets) {
Set result = new HashSet(first);
for (Collection set : sets) {
result.retainAll(set);
}
return result;
}
// @SafeVarargs
public static Collection remove(Collection first, Collection... sets) {
Set result = new HashSet(first);
for (Collection set : sets) {
result.removeAll(set);
}
return result;
}
public static boolean hasOverlap(Collection source, Collection... toBeChecked) {
for (T t : source) {
for (Collection l : toBeChecked) {
for (T r : l) {
if (t.equals(r))
return true;
}
}
}
return false;
}
}