package api.common.util; import java.util.*; public class CollectionUtil { public static List arrayToList(T[] array) { return Arrays.asList(array); } @SafeVarargs public static ArrayList createArrayList(T... elements) { return new ArrayList<>(Arrays.asList(elements)); } @SafeVarargs public static HashSet createHashSet(T... elements) { return new HashSet<>(Arrays.asList(elements)); } public static Set listToSet(List list) { return new HashSet<>(list); } public static List setToList(Set set) { return new ArrayList<>(set); } public static boolean isEmpty(Collection collection) { return collection == null || collection.isEmpty(); } public static boolean isEmpty(ArrayList arrayList) { return arrayList == null || arrayList.isEmpty(); } public static boolean isEmpty(Map map) { return map == null || map.isEmpty(); } public static boolean isNotEmpty(Collection collection) { return !isEmpty(collection); } public static boolean isNotEmpty(Map map) { return !isEmpty(map); } public static void addValueToMap(Map map, int value, String key) { map.merge(key, value, Integer::sum); } }