检查集合是否包含数组中的任何元素
import java.util.ArrayList; import java.util.Arrays; /* from nowjava - 时 代 Java */ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; public class Main{ public static <T> boolean containsAny(Set<T> set, T... elements) { return !Collections.disjoint(set, newCollection(elements)); } public static <T> Collection<T> newCollection(Collection<T> collection) { if (isNotEmpty(collection)) { ArrayList<T> arrayList = new ArrayList<T>(collection.size()); arrayList.addAll(collection);/*时 代 J a v a 公 众 号 - N o w J a v a . c o m 提 供*/ return arrayList; } return new ArrayList<T>(); } public static <T> Collection<T> newCollection(T... elements) { return newList(elements); } public static <T> Boolean isNotEmpty(Collection<T> collection) { return !isEmpty(collection); } public static <T> List<T> newList(T... elements) { if (GeneralUtil.isNotNull(elements)) { ArrayList<T> arrayList = new ArrayList<T>(elements.length); arrayList.addAll(Arrays.asList(elements)); return arrayList; } return new ArrayList<T>(); } public static <T> Boolean isEmpty(Collection<T> collection) { if (GeneralUtil.isNull(collection)) return Boolean.TRUE; return collection.isEmpty(); } public static <T> List<T> asLi