package com.ruoyi.common.mybatis.typehandler;

import org.apache.commons.lang3.StringUtils;

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

/**
 * @author wjh
 * 2024/12/7
 */
public class LongSplitListTypeHandler extends AbstractSplitListTypeHandler<Long>{
    /**
     * 转换为列表
     *
     * @param data
     * @param delimiter
     */
    @Override
    public List<Long> parseToList(String data, String delimiter) {
        if (StringUtils.isBlank(data)) {
            return new ArrayList<>();
        }
        String[] split = data.split(delimiter);
        return Arrays.stream(split)
                .filter(Objects::nonNull)
                .map(Long::valueOf)
                .collect(Collectors.toList());
    }
}
