package com.skr.mdm.util;


import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class MdmListUtil {

    /**
     * 差集
     *
     * @param equipmentIdList      下发的设备ID集合
     * @param existEquipmentIdList 已下发过的设备ID集合
     * @return
     */
    public static List<Integer> difference(List<Integer> equipmentIdList, List<Integer> existEquipmentIdList) {
        return Lists.newCopyOnWriteArrayList(Sets.difference(Sets.newHashSet(equipmentIdList), Sets.newHashSet(existEquipmentIdList)));
    }

    /**
     * 交集
     *
     * @param equipmentIdList      下发的设备ID集合
     * @param existEquipmentIdList 已下发过的设备ID集合
     * @return
     */
    public static List<Integer> intersection(List<Integer> equipmentIdList, List<Integer> existEquipmentIdList) {
        return Lists.newCopyOnWriteArrayList(Sets.intersection(Sets.newHashSet(equipmentIdList), Sets.newHashSet(existEquipmentIdList)));
    }
}
