liquibase.util.CollectionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-core Show documentation
Show all versions of liquibase-core Show documentation
Liquibase is a tool for managing and executing database changes.
package liquibase.util;
import java.util.*;
public class CollectionUtil {
public static Set> powerSet(Collection originalSet) {
Set> sets = new HashSet<>();
if (originalSet.isEmpty()) {
sets.add(new HashSet());
return sets;
}
List list = new ArrayList<>(originalSet);
T head = list.get(0);
Collection rest = list.subList(1, list.size());
for (Set set : powerSet(rest)) {
Set newSet = new HashSet<>();
newSet.add(head);
newSet.addAll(set);
sets.add(newSet);
sets.add(set);
}
return sets;
}
public static List