doum
6 天以前 2b287056e2f59518888d05a1bbc7e5a55fbd84d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.doumee.lib_coremodel.util;
 
import org.apache.commons.lang3.SerializationException;
import org.apache.commons.lang3.SerializationUtils;
 
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
 
public class ListUtils {
    public static boolean isNonOrEmpty(List<?> list){
        return list==null||list.size()==0;
    }
 
    public static boolean isNotNonOrEmpty(List<?> list){
        return list!=null&&list.size()!=0;
    }
 
    /**
     2      * 对集合进行深拷贝
     3      * 注意需要岁泛型类进行序列化(实现serializable)
     4      *
     5      * @param src
     6      * @param <T>
     7      * @return
     8      * @throws IOException
     9      * @throws ClassNotFoundException
     10      */
     public static <T> List<T> deepCopy(List<T> src) {
         //list深度拷贝
         List<T> newList = new ArrayList<>();
         try {
             newList = (List<T>) SerializationUtils.clone((Serializable) src);
         }catch (SerializationException e){
             e.printStackTrace();
         } catch (Exception e) {
             e.printStackTrace();
         }
         /*LogUtils.d("原list值:" + src);
         LogUtils.d("新list值:" + newList);*/
         return newList;
     }
 
    public static <T extends Serializable> T deepCopy(T src) {
        T t=null;
        try {
            t = (T) SerializationUtils.clone((Serializable) src);
        }catch (SerializationException e){
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
         /*LogUtils.d("原list值:" + src);
         LogUtils.d("新list值:" + newList);*/
        return t;
    }
 
}