zTreeDTO的clone实现,新增数据深拷贝
This commit is contained in:
parent
5379fab60a
commit
7db0f91c87
@ -13,7 +13,7 @@ import java.io.Serializable;
|
|||||||
* @Version: 1.0
|
* @Version: 1.0
|
||||||
**/
|
**/
|
||||||
@ApiModel
|
@ApiModel
|
||||||
public class ZTreeDTO implements Serializable {
|
public class ZTreeDTO implements Cloneable, Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1972916766961693525L;
|
private static final long serialVersionUID = 1972916766961693525L;
|
||||||
@ApiModelProperty(name = "id", value = "ID")
|
@ApiModelProperty(name = "id", value = "ID")
|
||||||
@ -107,6 +107,17 @@ public class ZTreeDTO implements Serializable {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
ZTreeDTO zTreeDTO = null;
|
||||||
|
try{
|
||||||
|
zTreeDTO = (ZTreeDTO) super.clone();
|
||||||
|
}catch (CloneNotSupportedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return zTreeDTO;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder sb = new StringBuilder("{");
|
final StringBuilder sb = new StringBuilder("{");
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.cm.common.utils;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When you feel like quitting. Think about why you started
|
||||||
|
* 当你想要放弃的时候,想想当初你为何开始
|
||||||
|
*
|
||||||
|
* @ClassName: ArrayListUtil
|
||||||
|
* @Description: 列表工具
|
||||||
|
* @Author: WangGeng
|
||||||
|
* @Date: 2020/8/24 17:25
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
public class ArrayListUtil {
|
||||||
|
|
||||||
|
public static <T extends Serializable> List<T> deepClone(List<? extends Serializable> sourceList, Class<T> clazz) {
|
||||||
|
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||||
|
try {
|
||||||
|
ObjectOutputStream out = new ObjectOutputStream(byteOut);
|
||||||
|
out.writeObject(sourceList);
|
||||||
|
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
|
||||||
|
ObjectInputStream inStream = new ObjectInputStream(byteIn);
|
||||||
|
List<T> destList = (List<T>) inStream.readObject();
|
||||||
|
return destList;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user