CollUtil.subtract增加空判定

This commit is contained in:
Looly 2024-06-04 08:47:34 +08:00
parent 6b4c3b1e4d
commit feba8fcb42

View File

@ -397,6 +397,10 @@ public class CollUtil {
* @return 单差集 * @return 单差集
*/ */
public static <T> Collection<T> subtract(final Collection<T> coll1, final Collection<T> coll2) { public static <T> Collection<T> subtract(final Collection<T> coll1, final Collection<T> coll2) {
if(isEmpty(coll1) || isEmpty(coll2)){
return coll1;
}
Collection<T> result = ObjUtil.clone(coll1); Collection<T> result = ObjUtil.clone(coll1);
if (null == result) { if (null == result) {
result = CollUtil.create(coll1.getClass()); result = CollUtil.create(coll1.getClass());