package com.example.removetolocal.utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zjm
 * @version 1.0.0
 * @ClassName StringUtils.java
 * @Description TODO
 * @createTime 2021年01月10日 16:20:00
 */
public class StringUtils {
    public static String ListToString(List<Integer> idList){
        StringBuffer stringBuffer=new StringBuffer();
        idList.forEach(
                i->stringBuffer.append(",").append(i)
        );
        return stringBuffer.toString();
    }

    public static List<Integer> stringToList(String idStirng){
        if (idStirng!=null) {
            List<String> idStringList = Arrays.asList(idStirng.split(","));
            return idStringList.stream().filter(list2 -> !list2.equals("")).map(Integer::parseInt).collect(Collectors.toList());
        }else {
            return new ArrayList<>();
        }
        }
}
