class CollectionUtils {

    public static <T> boolean hasIntersection(Set<T> a, Set<T> b) {
        if (isEmpty(a) || isEmpty(b)) {
            return false;
        }

        if (a.size() < b.size()) {
            if (a.size() < 8) {
                return a.stream().anyMatch(b::contains);
            } else {
                return a.parallelStream().anyMatch(b::contains);
            }
        } else {
            if (b.size() < 8) {
                return b.stream().anyMatch(a::contains);
            } else {
                return b.parallelStream().anyMatch(a::contains);
            }
        }
    }

}