多集合取交集公用方法

/**
	 * 多集合(过滤空集合)取交集retain公共方法
	 */
	public static Collection retain(Collection<Collection> c){
		Optional result = c.parallelStream()
				.filter(element -> CollectionUtils.isNotEmpty(element))
				.reduce((m1, m2)->{
			m1.retainAll(m2);
			return m1;
		});
		return (Collection) result.get();
	}

	/**
	 * 多集合(过滤空集合)取交集retain公共方法 参数String
	 */
	public static List<String> retainElementList(List<List<String>> elementLists) {
		Optional<List<String>> result = elementLists.parallelStream()
				.filter(elementList -> CollectionUtils.isNotEmpty(elementList))
				.reduce((a, b) -> {
					a.retainAll(b);
					return a;
				});
		return result.orElse(new ArrayList<>());
	}
每天一点点,惊喜不间断
原文地址:https://www.cnblogs.com/wszn-java/p/14754713.html