- /*
- * Will return all the unique combinations of the suggestions provided.
- * The order of the permutation is not taken into account when computing
- * the uniqueness.
- * e.g.: A list of A,B,C,D will return
- * [[A], [A, B, C, D], [A, C, D], [A, D], [B], [B, C, D], [B, D], [C], [C, D], [D]]
- *
- * @param list The list of statuses to create permutations of
- * @return A list which contains a array list of all possible combinations
- */
- public static ArrayList<ArrayList<String>> getUniqueListForSuggestions(
- List<String> originalList) {
- ArrayList<ArrayList<String>> lists = new ArrayList<ArrayList<String>>();
- if (originalList.isEmpty()) {
- lists.add(new ArrayList<String>());
- return lists;
- }
- List<String> list = new ArrayList<String>(originalList);
- String head = list.get(0);
- ArrayList<String> rest = new ArrayList<String>(list.subList(1, list.size()));
-
- for (ArrayList<String> activeList : getUniqueListForSuggestions(rest)) {
- ArrayList<String> newList = new ArrayList<String>();
- newList.add(head);
- newList.addAll(activeList);
- lists.add(newList);
- lists.add(activeList);
- }
- return lists;
- }
-
- public static ArrayList<ArrayList<String>> getNonEmptyUniqueLists(List<String> list){
- ArrayList<ArrayList<String>> lists = getUniqueListForSuggestions(list);
- // remove empty list from the power set
- for (ArrayList<String> emptyList : lists ){
- if ( emptyList.isEmpty() ) {
- lists.remove(emptyList);
- break;
- }
+ /*
+ * Will return all the unique combinations of the suggestions provided.
+ * The order of the permutation is not taken into account when computing
+ * the uniqueness.
+ * e.g.: A list of A,B,C,D will return
+ * [[A], [A, B, C, D], [A, C, D], [A, D], [B], [B, C, D], [B, D], [C], [C, D], [D]]
+ *
+ * @param list The list of statuses to create permutations of
+ * @return A list which contains a array list of all possible combinations
+ */
+ public static ArrayList<ArrayList<String>> getUniqueListForSuggestions(
+ List<String> originalList) {
+ ArrayList<ArrayList<String>> lists = new ArrayList<>();
+ if (originalList.isEmpty()) {
+ lists.add(new ArrayList<String>());
+ return lists;
+ }
+ List<String> list = new ArrayList<>(originalList);
+ String head = list.get(0);
+ ArrayList<String> rest = new ArrayList<>(list.subList(1, list.size()));
+
+ for (ArrayList<String> activeList : getUniqueListForSuggestions(rest)) {
+ ArrayList<String> newList = new ArrayList<>();
+ newList.add(head);
+ newList.addAll(activeList);
+ lists.add(newList);
+ lists.add(activeList);
+ }
+ return lists;