package com.tuoheng.admin;

import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.enums.AiAnalyseTypeEnum;
import org.apache.commons.collections4.CollectionUtils;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class Test {

    public static void main(String[] args) throws ParseException {
        Integer isLive = null;
        boolean online_condition = AiAnalyseTypeEnum.ONLINE.getCode() == isLive;
        boolean offline_condition = AiAnalyseTypeEnum.OFFLINE.getCode() == isLive;
        System.out.println("online_condition = " + online_condition);
        System.out.println("offline_condition = " + offline_condition);
    }

    public static void main2() {
        List<String> list1 = buildList1();
        List<String> list2 = buildList2();

        //并集
        Collection<String> union = CollectionUtils.union(list1, list2);

        //交集
        Collection<String> intersection = CollectionUtils.intersection(list1, list2);

        //交集的补集
        Collection<String> disjunction = CollectionUtils.disjunction(list1, list2);

        //集合相减
        Collection<String> subtract = CollectionUtils.subtract(list1, list2);

        //集合相减
        Collection<String> subtract2 = CollectionUtils.subtract(list2, list1);

        System.out.println("并集：" + union);
        System.out.println("交集" + intersection);
        System.out.println("交集的补集" + disjunction);
        System.out.println("集合相减" + subtract);
        System.out.println("集合相减" + subtract2);
    }

    private static List<String> buildList1() {
        List<String> list1 = new ArrayList<>();
        list1.add("a");
        list1.add("b");
        list1.add("c");
        return list1;
    }

    private static List<String> buildList2() {
        List<String> list2 = new ArrayList<>();
        list2.add("b");
        list2.add("e");
        list2.add("d");
        return list2;
    }

    private static List<String> jiao(List<String> oldList, List<String> newList) {
        // 交集
        oldList.retainAll(newList);
        System.out.println(oldList.toString()); // b
        return oldList;
    }

    private static List<String> bing(List<String> oldList, List<String> newList) {
        // 交集
        oldList.retainAll(newList);
        System.out.println(oldList.toString()); // b

        return oldList;
    }

    private static List<String> cha(List<String> oldList, List<String> newList) {
        // 差集
        oldList.retainAll(newList);
        System.out.println(oldList.toString()); // b

        return oldList;
    }
}
