diff --git a/cloud-common/src/main/java/com/cm/common/pojo/dtos/ZTreeDTO.java b/cloud-common/src/main/java/com/cm/common/pojo/dtos/ZTreeDTO.java index bd63554..90f94f7 100644 --- a/cloud-common/src/main/java/com/cm/common/pojo/dtos/ZTreeDTO.java +++ b/cloud-common/src/main/java/com/cm/common/pojo/dtos/ZTreeDTO.java @@ -13,7 +13,7 @@ import java.io.Serializable; * @Version: 1.0 **/ @ApiModel -public class ZTreeDTO implements Serializable { +public class ZTreeDTO implements Cloneable, Serializable { private static final long serialVersionUID = 1972916766961693525L; @ApiModelProperty(name = "id", value = "ID") @@ -107,6 +107,17 @@ public class ZTreeDTO implements Serializable { this.title = title; } + @Override + public Object clone() { + ZTreeDTO zTreeDTO = null; + try{ + zTreeDTO = (ZTreeDTO) super.clone(); + }catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + return zTreeDTO; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder("{"); diff --git a/cloud-common/src/main/java/com/cm/common/utils/ArrayListUtil.java b/cloud-common/src/main/java/com/cm/common/utils/ArrayListUtil.java new file mode 100644 index 0000000..26f10d5 --- /dev/null +++ b/cloud-common/src/main/java/com/cm/common/utils/ArrayListUtil.java @@ -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 List deepClone(List sourceList, Class 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 destList = (List) inStream.readObject(); + return destList; + } catch (IOException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + return null; + } + +}