import com.alibaba.fastjson.JSON;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class CollectionCopyUtil {
public static <T> List copyList(List<T> list,Class tClass) {
if (CollectionUtils.isEmpty(list)) {
return new ArrayList();
}
return JSON.parseArray(JSON.toJSONString(list), tClass);
}
public static Map<String, Object> copyMap(Map map) {
return JSON.parseObject(JSON.toJSONString(map));
}
}
网友评论