代码语言:javascript复制
public static <T> T clone(T object) {
if (object instanceof Collection) {
Collection co = (Collection) object;
return (T) clone(co);
} else if (object instanceof Map) {
Map map = (Map) object;
return (T) clone(map);
} else {
String s = JSON.toJSONString(object);
return (T) JSON.parseObject(s, object.getClass());
}
}