public static <A, B> boolean equalUnorderedCollections(
            Collection<A> colA, Collection<B> colB,
            final CrossTypeComparator<A, B> comparator) {
        if (colA == null || colB == null){
            if ( (colA == null || colA.isEmpty())
              && (colB == null || colB.isEmpty()) ) {
                return true;
            } else {
                return false;
            }
        }

        // Add all elements into sets to remove duplicates.
        Set<A> setA = new HashSet<A>();
        setA.addAll(colA);
        Set<B> setB = new HashSet<B>();
        setB.addAll(colB);

        if ( setA.size() != setB.size() ){
            return false;
        }

        for (A a : setA) {
            boolean foundA = false;
            for (B b : setB) {
                if (comparator.equals(a, b)) {
                    foundA = true;
                    break;
                }
            }
            if ( !foundA ) {
                return false;
            }
        }
        return true;
    }
Compares two unordered lists of different types, using the specified
cross-type comparator. Null collections are treated as empty ones.
Naively implemented using N(n^2) algorithm.
aws-java-sdk-test-utils/src/main/java/com/amazonaws/test/util/UnorderedCollectionComparator.java